Skip to content

Commit 36c452c

Browse files
solves longest increasing sub sequence
1 parent b8a4ba9 commit 36c452c

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
| 665 | [Non Deceasing Array](https://leetcode.com/problems/non-decreasing-array) | [![Java](assets/java.png)](src/NonDecreasingArray.java) [![Python](assets/python.png)](python/non_decreasing_array.py) |
175175
| 669 | [Trim a Binary Search Tree](https://leetcode.com/problems/trim-a-binary-search-tree) | [![Java](assets/java.png)](src/TrimABinarySearchTree.java) [![Python](assets/python.png)](python/trim_a_binary_search_tree.py) |
176176
| 671 | [Second Minimum Node in Binary Tree](https://leetcode.com/problems/second-minimum-node-in-a-binary-tree) | [![Java](assets/java.png)](src/SecondMinimumNodeInBinaryTree.java) [![Python](assets/python.png)](python/second_minimum_node_in_binary_tree.py) |
177-
| 674 | [Longest Continuous Increasing Subsequence](https://leetcode.com/problems/longest-continuous-increasing-subsequence) | |
177+
| 674 | [Longest Continuous Increasing Subsequence](https://leetcode.com/problems/longest-continuous-increasing-subsequence) | [![Java](assets/java.png)](src/LongestContinuousIncreasingSubsequence.java) [![Python](assets/python.png)](python/) |
178178
| 680 | [Valid Palindrome II](https://leetcode.com/problems/valid-palindrome-ii) | |
179179
| 682 | [Baseball Game](https://leetcode.com/problems/baseball-game) | |
180180
| 686 | [Repeated String Match](https://leetcode.com/problems/repeated-string-match) | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def findLengthOfLCIS(self, nums: List[int]) -> int:
6+
current, result = 1, 1
7+
for index in range(1, len(nums)):
8+
if nums[index] > nums[index - 1]:
9+
current += 1
10+
result = max(result, current)
11+
else:
12+
current = 1
13+
return result
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class LongestContinuousIncreasingSubsequence {
2+
public int findLengthOfLCIS(int[] nums) {
3+
int result = 1, current = 1;
4+
for (int index = 1 ; index < nums.length ; index++) {
5+
if (nums[index] > nums[index - 1]) {
6+
current++;
7+
result = Math.max(result, current);
8+
} else {
9+
current = 1;
10+
}
11+
}
12+
return result;
13+
}
14+
}

0 commit comments

Comments
 (0)