Topic:
1"a man, a plan, a Canal:panama"true2 "race a car"false
1. Problem-Solving ideas:
The subject is relatively simple, take the string directly before and after the letter to match, if the equality is forward, otherwise return error.
classSolution { Public: BOOLIspalindrome (strings) {intLen =s.size (); intStart =0; intEnd = len-1; while(Start <end) { CharFirst,second; /*get the fisrt char*/ while(Start <=end) { if((S[start] >='a'&& S[start] <='Z')||(S[start]>='A'&& S[start] <='Z')||(S[start]>='0'&& S[start] <='9') ) { First=S[start]; if(S[start] >='A'&& S[start] <='Z') { First= first-'A'+'a'; } Break; }Else{Start++; } } /*get the second char*/ while(Start <=end) { if((S[end] >='a'&& S[end] <='Z')||(S[end]>='A'&& S[end] <='Z')||(S[end]>='0'&& S[end] <='9') ) {Second=S[end]; if(Second <='Z'&&second>='A') {Second= second-'A'+'a'; } Break; }Else{End--; } } if(Start >end) { Break; } if(First = =second) {Start++; End--; }Else{ return false; } } return true; }};
"Primary Algorithm" 16. Validating palindrome strings