Solution { public static boolean isOneLetterDiff(String a, String b) { int diffs = 0; for (int i = 0; i < a.length(); i++) { if (a.charAt(i) != b.charAt(i)) { diffs++; if (diffs == 2) { return false; } } } return diffs == 1; }  List<List<String>> findLadders(String beginWord, String endWord, Set<String> wordList); static boolean isOneLetterDiff(String a, String b);  }
@Test public void shouldTellIfIsOneLetterDiff() throws Exception { boolean isOneLetterDiff = Solution.isOneLetterDiff("hot", "hit"); assertTrue(isOneLetterDiff); isOneLetterDiff = Solution.isOneLetterDiff("hot", "hao"); assertFalse(isOneLetterDiff); }