File tree 3 files changed +55
-0
lines changed
solution/0600-0699/0657.Robot Return to Origin
3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,26 @@ class Solution {
72
72
}
73
73
```
74
74
75
+ ### ** TypeScript**
76
+
77
+ ``` ts
78
+ function judgeCircle(moves : string ): boolean {
79
+ let x = 0 , y = 0 ;
80
+ const dir = {
81
+ R: [1 , 0 ],
82
+ L: [- 1 , 0 ],
83
+ U: [0 , 1 ],
84
+ D: [0 , - 1 ]
85
+ };
86
+ for (let u of moves ) {
87
+ const [dx, dy] = dir [u ];
88
+ x += dx ;
89
+ y += dy ;
90
+ }
91
+ return ! x && ! y ;
92
+ };
93
+ ```
94
+
75
95
### ** ...**
76
96
77
97
```
Original file line number Diff line number Diff line change @@ -89,6 +89,26 @@ class Solution {
89
89
}
90
90
```
91
91
92
+ ### ** TypeScript**
93
+
94
+ ``` ts
95
+ function judgeCircle(moves : string ): boolean {
96
+ let x = 0 , y = 0 ;
97
+ const dir = {
98
+ R: [1 , 0 ],
99
+ L: [- 1 , 0 ],
100
+ U: [0 , 1 ],
101
+ D: [0 , - 1 ]
102
+ };
103
+ for (let u of moves ) {
104
+ const [dx, dy] = dir [u ];
105
+ x += dx ;
106
+ y += dy ;
107
+ }
108
+ return ! x && ! y ;
109
+ };
110
+ ```
111
+
92
112
### ** ...**
93
113
94
114
```
Original file line number Diff line number Diff line change
1
+ function judgeCircle ( moves : string ) : boolean {
2
+ let x = 0 , y = 0 ;
3
+ const dir = {
4
+ R : [ 1 , 0 ] ,
5
+ L : [ - 1 , 0 ] ,
6
+ U : [ 0 , 1 ] ,
7
+ D : [ 0 , - 1 ]
8
+ } ;
9
+ for ( let u of moves ) {
10
+ const [ dx , dy ] = dir [ u ] ;
11
+ x += dx ;
12
+ y += dy ;
13
+ }
14
+ return ! x && ! y ;
15
+ } ;
You can’t perform that action at this time.
0 commit comments