Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit92b83df

Browse files
authored
Backspace String Compare
1 parent720db95 commit92b83df

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#Solution
2+
```
3+
class Solution:
4+
def backspaceCompare(self, S, T):
5+
S = Solution.ls(self, S)
6+
T = Solution.ls(self, T)
7+
if len(S) == len(T):
8+
for x in range(len(S)):
9+
if S[x] != T[x]:
10+
return False
11+
return True
12+
else:
13+
return False
14+
15+
def ls(self, arr):
16+
arr = list(arr)
17+
start = 0
18+
for x in range(len(arr)):
19+
if arr[x] == '#':
20+
if start > 0:
21+
start -= 1
22+
else:
23+
continue
24+
else:
25+
arr[start] = arr[x]
26+
start += 1
27+
return arr[:start]
28+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp