Submission Detail

361 / 361 test cases passed.
Status:

Accepted

Runtime: 127 ms
Memory Usage: 14.5 MB
Submitted: 1 week, 1 day ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

40
60
80
100
120
140
160
180
200
220
1
2
3
4
5
6
python
You are here!
Your runtime beats 17.73 % of python submissions.
Runtime (ms)
Distribution (%)

40
60
80
100
120
140
160
180
200
220
2
4
6
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

14500
14000
14100
14200
14300
14400
14600
14700
14800
14900
15000
2.5
5.0
7.5
10.0
12.5
15.0
python
You are here!
Your memory usage beats 80.06 % of python submissions.
Memory (KB)
Distribution (%)

14500
14000
14100
14200
14300
14400
14600
14700
14800
14900
15000
5
10
15
Zoom area by dragging across this chart

Invite friends to challenge Remove Duplicates from Sorted Array


Submitted Code: 1 week, 1 day ago

Language: python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
seen = []
count = len(nums)
i = 0
while (i < len(nums)):
if (nums[i] not in seen):
seen.append(nums[i])
i += 1
continue
if (nums[i] in seen):
nums[i] = 999
i += 1
count -= 1
j = 0
curr = 0 # current 999 index to be replaced
fresh = 0 # current fresh index to replace next 999
while (j < len(nums)):
if (nums[j] == 999 or nums[j] == 998):
curr = j
if (fresh == 0):
fresh = j + 1
if (fresh < len(nums)):
while (nums[fresh] == 999 or nums[fresh] == 998):
if (fresh == len(nums)-1):
break
fresh += 1
nums[curr] = nums[fresh]
nums[fresh] = 998
fresh += 1
j += 1
return count
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX