Skip to content

Instantly share code, notes, and snippets.

@prampcontent
prampcontent / ShotestCellPath.java
Created March 27, 2019 11:09
ShortestCellPath-Java
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};
tests = [
(input, expected-output),
. . .
]
for (test in tests) {
print “input: { test[0] }, expected output: { test[1] }, actual output: { doThing(test[0]) }”
}
input = [ . . . ]
left = 0
right = input.length()
while (left < right) {
. . .
left++
right--
}
for (i = 0; i < input.length(); i++) {
for (j = 0; j < input[i].length(); j++) {
doThing();
}
}