File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 15
15
| 14 | [ Longest Common Prefix] ( https://leetcode.com/problems/longest-common-prefix/ ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/LongestCommonPrefix.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/longest_common_prefix.py ) |
16
16
| 20 | [ ValidParentheses] ( https://leetcode.com/problems/valid-parentheses/ ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/ValidParentheses.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/valid_parentheses.py ) |
17
17
| 21 | [ Merge 2 Sorted Lists] ( https://leetcode.com/problems/merge-two-sorted-lists/ ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/Merge2SortedLists.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/merge_2_sorted_lists.py ) |
18
- | 26 | [ Remove Duplicates From Sorted Array] ( https://leetcode.com/problems/remove-duplicates-from-sorted-array/ ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/RemoveDuplicatesFromSortedArray.java ) |
18
+ | 26 | [ Remove Duplicates From Sorted Array] ( https://leetcode.com/problems/remove-duplicates-from-sorted-array/ ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/RemoveDuplicatesFromSortedArray.java ) [ ![ Python ] ( https://img.icons8.com/color/35/000000/python.png )] ( python/remove_duplicates_from_sorted_array.py ) |
19
19
| 27 | [ Remove Element] ( https://leetcode.com/problems/remove-element/ ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/RemoveElement.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/remove_element.py ) |
20
20
| 28 | [ Needle in Haystack] ( https://leetcode.com/problems/implement-strstr ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/NeedleInHaystack.java ) [ ![ Python] ( https://img.icons8.com/color/35/000000/python.png )] ( python/needle_in_haystack.py ) |
21
21
| 35 | [ Search Inserted Position] ( https://leetcode.com/problems/search-insert-position/ ) | Easy | [ ![ Java] ( https://img.icons8.com/color/40/000000/java-coffee-cup-logo.png )] ( src/SearchInsertPosition.java ) |
Original file line number Diff line number Diff line change
1
+ from typing import List
2
+
3
+
4
+ class Solution :
5
+ def removeDuplicates (self , array : List [int ]) -> int :
6
+ if len (array ) == 0 :
7
+ return 0
8
+
9
+ position = 1
10
+ previouslyEncountered = array [0 ]
11
+ for index in range (1 , len (array )):
12
+ if array [index ] != previouslyEncountered :
13
+ array [position ] = array [index ]
14
+ position += 1
15
+ previouslyEncountered = array [index ]
16
+
17
+ return position
You can’t perform that action at this time.
0 commit comments