LAGUREN.NET
  • HOME
  • About Me

Afterthoughts - How I should have answered the interview question

7/7/2015

 
Question:  Determine if two strings are anagrams.  For example, listen and silent are anagrams.
My Solution In Ruby:

"listen".chars.sort { |a, b| a.casecmp(b) } .join == "silent".chars.sort { |a, b| a.casecmp(b) } .join ? "They are anagrams" : "They are NOT anagrams"

    RSS Feed

    Categories

    All
    Advice
    Agile
    Android
    Automation
    BDD
    C9D9
    Capybara
    Career
    Continuous Delivery
    Continuous Integration
    Cucumber
    Database
    Ebates
    Firefox
    Fiverr
    GIT
    Groupon
    Interview
    Investing
    Jenkins
    JIRA
    Jmeter
    Jobs
    Meetup
    Melvinisms
    Metaprogramming
    Mobile
    Ruby
    Stockpile
    Training

© COPYRIGHT 2018. ALL RIGHTS RESERVED.
  • HOME
  • About Me