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 0aa92f4 commit c3945a0Copy full SHA for c3945a0
3552-grid-teleportation-traversal.js
@@ -37,7 +37,7 @@ var minMoves = function (matrix) {
37
if (x === n - 1 && y === m - 1) return curDist
38
39
if (
40
- matrix[x][y].toUpperCase()===matrix[x][y] &&
+ isUpper(matrix[x][y]) &&
41
!used.has(matrix[x][y])
42
) {
43
used.add(matrix[x][y])
@@ -66,6 +66,13 @@ var minMoves = function (matrix) {
66
67
return -1
68
}
69
+
70
+function isUpper(ch) {
71
+ const A = 'A'.charCodeAt(0)
72
+ const Z = 'Z'.charCodeAt(0)
73
+ const code = ch.charCodeAt(0)
74
+ return code >= A && code <= Z
75
+}
76
function isValid(i, j, n, m, matrix) {
77
if (i < 0 || j < 0 || i >= n || j >= m) return false
78
if (matrix[i][j] === '#') return false
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments