Skip to content
Exercise · Strings · lesson 8 of 8

Exercise: palindrome

Write a function func isPalindrome(s string) bool that returns true if the string reads the same from left to right and from right to left. Letter case and spaces do not count.

  • isPalindrome("Level") → true
  • isPalindrome("hello") → false
  • isPalindrome("А роза упала на лапу Азора") → true

Constraints: the string consists of Latin and Russian letters and spaces, with at least one letter; spaces may come at the start, at the end and several in a row.

Do not add extra imports unless the task says so explicitly.

palindrome.go — go
go · 6 lines
Ctrl+Enter run · Esc leave editor

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way