Skip to content

Commit 7f106bb

Browse files
authored
Create Tony the Cyclist.md
1 parent 8d02073 commit 7f106bb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
```java
2+
class Solution {
3+
public boolean checkPossibility(int[] nums) {
4+
if(nums.length < 2){
5+
return true;
6+
}
7+
int cot = 0;
8+
int index;
9+
if(nums[0] > nums[1]){
10+
cot = 1;
11+
}
12+
int len = nums.length - 1;
13+
for (int i = 1; i < len; i ++){
14+
if (cot > 1){
15+
return false;
16+
}
17+
if (nums[i] > nums[i+1]){
18+
if(nums[i-1] >= nums[i+1]){
19+
nums[i+1] = nums[i];
20+
21+
}
22+
else {
23+
nums[i] = nums[i-1];
24+
}
25+
//len--;
26+
//i--;
27+
cot++;
28+
}
29+
}
30+
if (cot > 1){
31+
return false;
32+
}
33+
return true;
34+
}
35+
}
36+
```

0 commit comments

Comments
 (0)