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

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Strings
  4. Super Reduced String
  5. Discussions

Super Reduced String

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • midoutn
    2 months ago+ 0 comments

    C# solution

    public static string superReducedString(string s)
        {
     string d,e;
                for(int i=0;i<s.Length-1;i++)
                {
                   d= s.Substring(i,  1);
                    e = s.Substring(i+1, 1);
                    if (e == d)
                    { 
                        s=s.Remove(i, 2);
                        if (i == 0) i = i - 1;
                        else
    
                            i = i - 2;
                    }
                }
    if (s.Length<1) 
    {
        s="Empty String";
        }
                return s;
        }
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy