Submission Detail

58 / 58 test cases passed.
Status:

Accepted

Runtime: 24 ms
Memory Usage: 14 MB
Submitted: 1 minute ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

0
5
10
15
20
25
30
35
40
45
50
55
2
4
6
8
10
12
python
You are here!
Your runtime beats 36.63 % of python submissions.
Runtime (ms)
Distribution (%)

0
5
10
15
20
25
30
35
40
45
50
55
5
10
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

13200
13250
13300
13350
13400
13450
13500
13550
13600
13650
13700
13750
13800
13850
13900
5
10
15
20
25
30
35
python
Memory (KB)
Distribution (%)

13200
13250
13300
13350
13400
13450
13500
13550
13600
13650
13700
13750
13800
13850
13900
10
20
30
Zoom area by dragging across this chart

Invite friends to challenge Reverse Words in a String


Submitted Code: 1 minute 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
class Solution(object):
def reverseWords(self, s):
"""
:type s: str
:rtype: str
"""
s = s.strip()
word = []
rW = []
last_char = s[0]
# split words
for i in range(0,len(s)):
if (i != 0):
last_char = s[i-1]
if (s[i] != ' '):
word.append(s[i])
elif (s[i] == ' ' and last_char != ' '):
rW.append(word)
word = []
rW.append(word)
rW.reverse()
# reverse
reversedWord = ""
for w in rW:
reversedWord = reversedWord + "".join(w) + " "
reversedWord = reversedWord.rstrip()
return reversedWord
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX