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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Strings
  4. Making Anagrams
  5. Discussions

Making Anagrams

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

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

  • snkt_pat2
    6 years ago+ 5 comments

    passed all test cases in 0s

    string in1,in2;
    cin>>in1>>in2;
    int array[26] = {0};
    for(int i=0;i<in1.length();i++)
        array[in1[i]-'a']++;
    for(int i=0;i<in2.length();i++)
        array[in2[i]-'a']--;
    int sum = 0;
    for(int i=0;i<26;i++)
        sum+=abs(array[i]);
    cout<<sum;
    return 0;
    
    26|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature