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 f4050e3 commit 9bd970eCopy full SHA for 9bd970e
jump-game/Leo.py
@@ -0,0 +1,18 @@
1
+class Solution:
2
+ def canJump(self, nums: List[int]) -> bool:
3
+ target = len(nums) - 1
4
+
5
+ for i in range(target, -1, -1):
6
+ if i + nums[i] >= target:
7
+ target = i
8
9
+ return True if target == 0 else False
10
11
+ # maxReach = 0
12
+ # for i, jump in enumerate(nums):
13
+ # if i > maxReach:
14
+ # return False
15
+ # maxReach = max(maxReach, i + jump)
16
+ # return True
17
18
+ ## Both TC: O(n), SC: O(1)
maximum-subarray/Leo.py
@@ -0,0 +1,16 @@
+ def maxSubArray(self, nums: List[int]) -> int:
+ maxSub = nums[0]
+ curSum = 0
+ for n in nums:
+ if curSum < 0:
+ curSum += n
+ maxSub = max(curSum, maxSub)
+ return maxSub
+ ## TC: O(n), SC: O(1)
0 commit comments