Could you tell me that my solution is enough good or not?


  • 0
    T

    public class ReveserString {
    public ReveserString(String st){

    	System.out.println(st);
    	
    	ArrayList<String> sb = new ArrayList<String>();		
    	int i = 0;
    	
    	
    	for (String word: st.split(" ", 0)){			
    		sb.add(word);
    		i++;		
    	}		
    
    	System.out.println("Reverse the string word by word:");
    	
    	for (int j=i-1; j>=0; j--){
    		System.out.print(sb.get(j)+" ");			
    	}
    	
    	
    }
    

    }


Log in to reply
 

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