We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6dbb29e commit c4eef37Copy full SHA for c4eef37
Leetcode_30day_challenge/Increasing_Triplet_Subsequence.py
@@ -0,0 +1,15 @@
1
+# Solution - 1: Time: O(N)
2
+class Solution:
3
+ def increasingTriplet(self, nums: List[int]) -> bool:
4
+ # Set both the first and the second values as MAX value
5
+ first = second = float('inf')
6
+
7
+ for i in nums:
8
+ if i <= first: # This will ensure that we always store the minimum value in first
9
+ first = i
10
+ elif i <= second: # This will ensure that we always store a value greater than first
11
+ second = i
12
+ else: # If we have reached here, we have seen a value greater than first and second. So return True
13
+ return True
14
15
+ return False
0 commit comments