File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 121
121
| 700| [ 二叉搜索树中的搜索] ( https://leetcode.cn/problems/search-in-a-binary-search-tree/ ) | [ JavaScript] ( ./algorithms/search-in-a-binary-search-tree.js ) | Easy|
122
122
| 704| [ 二分查找] ( https://leetcode.cn/problems/binary-search/ ) | [ JavaScript] ( ./algorithms/binary-search.js ) | Easy|
123
123
| 707| [ 设计链表] ( https://leetcode.cn/problems/design-linked-list/ ) | [ JavaScript] ( ./algorithms/design-linked-list.js ) | Medium|
124
+ | 844| [ 比较含退格的字符串] ( https://leetcode.cn/problems/backspace-string-compare/ ) | [ JavaScript] ( ./algorithms/backspace-string-compare.js ) | Easy|
124
125
| 876| [ 链表的中间结点] ( https://leetcode.cn/problems/middle-of-the-linked-list/ ) | [ JavaScript] ( ./algorithms/middle-of-the-linked-list.js ) | Easy|
125
126
| 897| [ 递增顺序搜索树] ( https://leetcode.cn/problems/increasing-order-search-tree/ ) | [ JavaScript] ( ./algorithms/increasing-order-search-tree.js ) | Easy|
126
127
| 912| [ 排序数组] ( https://leetcode.cn/problems/sort-an-array/ ) | [ JavaScript] ( ./algorithms/sort-an-array.js ) | Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {string } s
3
+ * @param {string } t
4
+ * @return {boolean }
5
+ */
6
+ var backspaceCompare = function ( s , t ) {
7
+ let sStr = "" ;
8
+ let tStr = "" ;
9
+
10
+ for ( let c of s ) {
11
+ if ( c === "#" ) {
12
+ sStr = sStr . slice ( 0 , - 1 ) ;
13
+ } else {
14
+ sStr += c ;
15
+ }
16
+ }
17
+ for ( let c of t ) {
18
+ if ( c === "#" ) {
19
+ tStr = tStr . slice ( 0 , - 1 ) ;
20
+ } else {
21
+ tStr += c ;
22
+ }
23
+ }
24
+
25
+ return sStr === tStr ;
26
+ } ;
You can’t perform that action at this time.
0 commit comments