1mg interview question

write a program to find 1st non-repeating character from a string.

Interview Answers

Anonymous

2 Aug 2019

private void findNonRepeatingCharacter(String str) { char[] arr = str.toCharArray(); for (char a : arr) { if (str.indexOf(a) == str.lastIndexOf(a)) { System.out.println(a + " is first non repeating char"); break; } } }

Anonymous

26 Sept 2019

using linked hash map is eaay options