C# recursive attempt Memory Limit Exceded


  • 0

    I'm not sure why this doesn't pass

        public string ReverseString(string s) {
          if(s.Length < 2){
              return s;
          }
          var last = s[s.Length - 1];
          var sub = s.Substring(0, s.Length - 1);
          return last + ReverseString(sub);
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.