We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2b97495 commit 846fd74Copy full SHA for 846fd74
Problems/24-Where-Will-the-Ball-Fall/1706.ts
@@ -0,0 +1,33 @@
1
+function findBall(grid: number[][]): number[] {
2
+ let m = grid.length;
3
+ let n = grid[0].length;
4
+ let res: number[] = [];
5
+
6
+ for (let i = 0; i < n; i++) {
7
+ let x = 0,
8
+ y = i;
9
+ while (x < m) {
10
+ if (grid[x][y] === 1) {
11
+ if (y === n - 1) {
12
+ break;
13
+ } else if (grid[x][y + 1] === -1) {
14
15
+ }
16
+ x++;
17
+ y++;
18
+ } else {
19
+ if (y === 0) {
20
21
+ } else if (grid[x][y - 1] === 1) {
22
23
24
25
+ y--;
26
27
28
+ if (x === m) {
29
+ res.push(y);
30
+ } else res.push(-1);
31
32
+ return res;
33
+}
0 commit comments