问题描述
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
Examples:
s = "leetcode"return 0.s = "loveleetcode",return 2.
Java算法实现
public class Solution { public int firstUniqChar(String s) { TreeSetset=new TreeSet (); Map unique=new HashMap (); for(int i=0;i 0){ index=(int) values[0]; for(int i=1;i