π Back to Blog
- Two strings are anagrams if they contain the same letters, but not necessarily in the same order.
- βcarβ and βarcβ are anagrams
- The key to determining if 2 strings are anagrams is to sort them. If the sorted strings are the same, they are anagrams.
- Rules for creating an algorithm to determine if 2 strings are an anagram
- remove spaces in the words
- convert all letters to lowercase
- trim spaces if necessary
- sort the strings
- compare the strings to see if they are the same
- A palindrome is a word that reads the same backword as forward
- Hannah, mom, wow, and racecar are all examples of palindromes
- A simple way to see if a string is a palindrome is to copy it and compare the copy to the original. If they are equal, the string is a palindrome.