Advertisement
lazar955

Untitled

Oct 22nd, 2023
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. func isPalindrome(s string) bool {
  2. f:= func(r rune) rune {
  3. if !unicode.IsLetter(r) && !unicode.IsNumber(r) {
  4. return -1
  5. }
  6. return unicode.ToLower(r)
  7. }
  8. s = strings.Map(f,s)
  9. i,j:= 0, len(s) -1
  10. for i<j {
  11. if s[i] !=s[j] {
  12. return false
  13. }
  14. i++
  15. j--
  16. }
  17. return true
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement