Skip to content

Commit aeaf019

Browse files
committed
leetcode 28
1 parent b95fe70 commit aeaf019

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

solution.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,37 @@ def removeElement(self, nums, val):
484484
:type val: int
485485
:rtype: int
486486
"""
487+
if len(nums) == 0:
488+
return 0
489+
j = 0
490+
for i in range(len(nums)):
491+
if nums[i] != val:
492+
nums[j] = nums[i]
493+
j += 1
494+
495+
return j
496+
497+
# leetcode28
498+
def strStr(self, haystack, needle):
499+
"""
500+
:type haystack: str
501+
:type needle: str
502+
:rtype: int
503+
"""
504+
pos = haystack.find(needle)
505+
return pos
506+
507+
# leetcode29
508+
def divide(self, dividend, divisor):
509+
"""
510+
:type dividend: int
511+
:type divisor: int
512+
:rtype: int
513+
"""
514+
487515
pass
488516

489517

490518

491519
if __name__ == '__main__':
492-
print Solution().removeDuplicates([0,0,1,1,1,2,2,3,3,4])
520+
print Solution().strStr('hello','lll')

0 commit comments

Comments
 (0)