I am getting runtime exception.Can someone plz help me whats the error??


  • 0
    A

    public class Solution {
    public String reverseStr(String s, int k) {
    char[] charArray=s.toCharArray();
    StringBuilder reversed = new StringBuilder();
    StringBuilder sb = new StringBuilder();
    for(int i=0;i<k;i++)
    {
    reversed.append(charArray[i]);

        } 
        sb.append(reversed.reverse());
    for(int i=k ; i<charArray.length;i++ ){
        sb.append(charArray[i]);
    }
        
       return(sb.toString());
        
    }
    

    }


Log in to reply
 

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