@Test public void testGetLongestString() { String[] input = new String[] { "Yuri", "Interview", "Nordstrom", "Cat", "Dog", "Telephone", "AVeryLongString", "This code puzzle is easy" }; Assert.assertEquals("This code puzzle is easy", assignment.getLongestString(1, Arrays.asList(input))); }
public String getLongestString(int n, List<String> inputs) { int[] lengths = new int[inputs.size()]; MultiValueMap<Integer, Integer> lengthToIndicesMap = new MultiValueMap<>(); int len = -1; for (int i = 0; i < inputs.size(); i++) { len = inputs.get(i).length(); lengths[i] = len; lengthToIndicesMap.put(len, i); } int maxLen = quickselect(lengths, 0, inputs.size() - 1, n - 1); return inputs.get(lengthToIndicesMap.getCollection(maxLen).iterator().next()); }
Assignment { public String getLongestString(int n, List<String> inputs) { int[] lengths = new int[inputs.size()]; MultiValueMap<Integer, Integer> lengthToIndicesMap = new MultiValueMap<>(); int len = -1; for (int i = 0; i < inputs.size(); i++) { len = inputs.get(i).length(); lengths[i] = len; lengthToIndicesMap.put(len, i); } int maxLen = quickselect(lengths, 0, inputs.size() - 1, n - 1); return inputs.get(lengthToIndicesMap.getCollection(maxLen).iterator().next()); } }
Assignment { public String getLongestString(int n, List<String> inputs) { int[] lengths = new int[inputs.size()]; MultiValueMap<Integer, Integer> lengthToIndicesMap = new MultiValueMap<>(); int len = -1; for (int i = 0; i < inputs.size(); i++) { len = inputs.get(i).length(); lengths[i] = len; lengthToIndicesMap.put(len, i); } int maxLen = quickselect(lengths, 0, inputs.size() - 1, n - 1); return inputs.get(lengthToIndicesMap.getCollection(maxLen).iterator().next()); }  }
Assignment { public String getLongestString(int n, List<String> inputs) { int[] lengths = new int[inputs.size()]; MultiValueMap<Integer, Integer> lengthToIndicesMap = new MultiValueMap<>(); int len = -1; for (int i = 0; i < inputs.size(); i++) { len = inputs.get(i).length(); lengths[i] = len; lengthToIndicesMap.put(len, i); } int maxLen = quickselect(lengths, 0, inputs.size() - 1, n - 1); return inputs.get(lengthToIndicesMap.getCollection(maxLen).iterator().next()); }  String getLongestString(int n, List<String> inputs); boolean isPermutationOfEachOther(String s, String t); }
Assignment { public String getLongestString(int n, List<String> inputs) { int[] lengths = new int[inputs.size()]; MultiValueMap<Integer, Integer> lengthToIndicesMap = new MultiValueMap<>(); int len = -1; for (int i = 0; i < inputs.size(); i++) { len = inputs.get(i).length(); lengths[i] = len; lengthToIndicesMap.put(len, i); } int maxLen = quickselect(lengths, 0, inputs.size() - 1, n - 1); return inputs.get(lengthToIndicesMap.getCollection(maxLen).iterator().next()); }  String getLongestString(int n, List<String> inputs); boolean isPermutationOfEachOther(String s, String t);  }