From the course: Nail Your C# Interview

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Solution: Developing a palindrome checker

Solution: Developing a palindrome checker - C# Tutorial

From the course: Nail Your C# Interview

Solution: Developing a palindrome checker

(music) - [Instructor] Let's implement a palindrome checker. A palindrome is a word or phrase which reads the same backwards as it does forwards. To start, we'll create a lowercased version of the original string and normalize it to a common form. Then, we'll build a reverse string by iterating through the normalized string and adding each character in reverse. We're using a StringBuilder because it lets us represent a mutable string of characters. The regular string data type is not mutable, so, since we're doing so many mutations, it would not be efficient to use it. Let's iterate through the string. At the end of our function, we'll check if the reverse string equals our normalized string. If they're equal, then the original string must be a palindrome. Let's see if this works. Our implementation works as expected, but we could make it more efficient. In fact, we could eliminate the creation of strings almost entirely by cleverly checking certain indices of the original string. We…

Contents