Skip to content

Commit d91665b

Browse files
committed
Time: 3 ms (17.90%) | Memory: 17.7 MB (88.19%) - LeetSync
1 parent 35ddfae commit d91665b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def countHillValley(self, nums: List[int]) -> int:
3+
ans = 0
4+
no_duplicate = [nums[0]]
5+
for i in range(1, len(nums)):
6+
if no_duplicate[-1] !=nums[i]:
7+
no_duplicate.append(nums[i])
8+
print(no_duplicate)
9+
for i in range(1, len(no_duplicate)-1):
10+
if no_duplicate[i-1] < no_duplicate[i] > no_duplicate[i+1] or no_duplicate[i-1] >no_duplicate[i] < no_duplicate[i+1]:
11+
ans +=1
12+
return ans

0 commit comments

Comments
 (0)