We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  • Hiring developers?
  1. Practice
  2. Algorithms
  3. Strings
  4. Anagram
  5. Discussions

Anagram

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial
  • Topics

    You are viewing a single comment's thread. Return to all comments →

  • Sasintheran 3 years ago+ 1 comment

    can you please explain the term...

    letter[c-'a']++;

    I can't understand this line...how its works? explain me please...

    0|
    ParentPermalink
    • aquio 3 years ago+ 0 comments

      letter is a frequency array - you count how many appearances of each letter of alphabet are there in your string. So, at letter[0] you have frequency for 'a', at letter[1] for 'b' etc. For example, if your c within the loop at some point is 'd', then 'd' - 'a' = 100 - 97 = 3, (100 and 97 are respective character codes) and you do required operation on letter[3]

      0|
      ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature