题目
class Solution {
public int firstUniqChar(String s) {
int[] sum = new int[26];
char[] num = s.toCharArray();
for(int i=0;i<num.length;i++) {
sum[num[i]-'a']++;
}
for(int j=0;j<num.length;j++) {
if(sum[num[j]-'a'] == 1) {
return j;
}
}
return -1;
}
}
题目
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
String[] sum = s.split(" ");
System.out.println(sum[sum.length-1].length());
sc.close();
}
}