Finding Anagrams using Objective-C

TL;DR: Solution can be found here.

Problem:

Given a list of words and a single word I had to find out if that single word is an anagram with any of the words in the list and return those words that are anagrams in an array.

Solution:

  1. A way to go about it is to sort the ‘single word’ and the list of words in the ‘array’ in alphabetical order.
  2. Compare the sorted strings in the array with the ‘single word’
  3. If equal, bingo, you have an anagram.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s