leetcode

Medium level Intuition: Seems like a straight forward question (leaning to an easy level). Since in Python you can't alter the legth of the array, we are going to iterate the given array while tracking the duplicate numbers, the position to insert, and the compared number. My Solution: class Solution: def removeDuplicates(self, nums: List[int]) -> int: tmp = 0 idx = 1 dup = False for i, num in e..
Medium Intuition: The problem might seem like a search problem at first because you are looking for a possible leap paths to the final index. But really, you just have to return the boolean value, so by thinking about maximum possible jumps, one can do this in linear time easily. Feels like some kind of greedy algorithm will work here. My solution: class Solution: def canJump(self, nums: List[in..
Coding Monkey
'leetcode' 태그의 글 목록