Find the first non-repeating character in a string.
Anonymous
import java.util.*; class FirstUniq{ public static void main(String[] args){ System.out.println(getFirstUniqChar("12")); } public static Character getFirstUniqChar(String s){ if (s == null || s.length() == 0) {return null;} Map map = new LinkedHashMap(); for(int i = 0; i e : map.entrySet()){ if (e.getValue() == 1) return e.getKey(); } return null; } }
Check out your Company Bowl for anonymous work chats.