This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.*; | |
| import java.util.*; | |
| class Solution { | |
| static int shortestCellPath(int[][] grid, int sr, int sc, int tr, int tc) { | |
| int[] dr = {-1, 0, 1, 0}; | |
| int[] dc = {0, -1, 0, 1}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tests = [ | |
| (input, expected-output), | |
| . . . | |
| ] | |
| for (test in tests) { | |
| print “input: { test[0] }, expected output: { test[1] }, actual output: { doThing(test[0]) }” | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input = [ . . . ] | |
| left = 0 | |
| right = input.length() | |
| while (left < right) { | |
| . . . | |
| left++ | |
| right-- | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for (i = 0; i < input.length(); i++) { | |
| for (j = 0; j < input[i].length(); j++) { | |
| doThing(); | |
| } | |
| } |