年迈的战士已经挂上了奥金斧,年轻的战士还在挨打(->我)
看完别人的代码再看我的代码就是一坨翔..
class Solution{
public:
int appearnum[300];
int firstloc[300];
char mat[100000];
int loc=0;
//Insert one char from stringstream
void insert(char ch){
mat[loc]=ch;loc++;
int k=(int)ch;
if(appearnum[k]==0){
firstloc[k]=loc-1;
}
appearnum[k]++;
}
//return the first appearence once char in current stringstream
char firstAppearingOnce(){
int minn=999;
char ret='#';
for(int i=0;i<=178;i++){
if(appearnum[i]==1){
if(firstloc[i]<minn){
minn=firstloc[i];
ret=(char)i;
}
}
}
return ret;
}
};