classSolution{char[] chs;
List<Integer>[] ind;publicintuniqueLetterString(String s){int mod =1000000007;
chs = s.toCharArray();
ind =newArrayList[26];// 每个字母出现过的下标位置int ans =0;int cur =0;for(int i =0; i < s.length(); i ++){int id = chs[i]-'A';if(ind[id]== null){
ind[id]=newArrayList<Integer>();
cur =(cur + i +1)% mod;}else{int frist = ind[id].get(ind[id].size()-1);int second =-1;if(ind[id].size()>1){// 之前不止出现一次
second = ind[id].get(ind[id].size()-2);}// 最近一次出现到当前之间的数字都+1
cur =(cur +(i - frist -1)+1)% mod;// 最近一次出现的位置到第二近出现的位置之间的数都-1
cur =(cur + mod -(frist - second))% mod;}
ans =(ans + cur)% mod;
ind[id].add(i);}return ans;}}
842. 将数组拆分成斐波那契序列class Solution { List<Integer> ans; char[] chars; int n; public boolean F(int fro, int f0, int f1, List<Integer> cur) { if (fro >= n) return false; int f2 = 0; for (int i = fro; i &l