-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_extra_char.cpp
More file actions
54 lines (43 loc) · 1.06 KB
/
Copy pathfind_extra_char.cpp
File metadata and controls
54 lines (43 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include"essentials.cpp"
// char findTheDifference(string s, string t) {
// char count[256];
// char x='\0';
// for(int i=0;i<s.length();i++){
// count[s[i]]++;
// }
// for(int j=0;j<t.length();j++){
// count[t[j]]--;
// if(count[t[j]]==-1){
// x=t[j];
// // cout<<x<<endl;
// // return x;
// }
// }
// return x;
// char x='\0';
// for(int i=0;i<s.length();i++){
// x=x^s[i];
// }
// for(int j=0;j<t.length();j++){
// x=x^t[j];
// }
// return x;
int lengthOfLastWord(string s) {
int count=0;
string c=" ";
for(int i=s.length()-1;i>=0;i--){
if(s[i]!=' '){
count++;
}
else{
break;
}
}
return count;
}
int main(){
string s="hello world";
string t="abc";
cout<<lengthOfLastWord(s)<<endl;
return 1;
}