(Coderbyte) First Reverse - Solução

Have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order.

Solução:

import java.util.*;
import java.io.*;

class Function { 
  String FirstReverse(String str) {
   
    String res = "";
    for (int i = str.length()-1; i >= 0; i--) {
        res += str.charAt(i); 
    }
   
    return res;
   
  }
 
  public static void main (String[] args) { 
    // keep this function call here    
    Scanner  s = new Scanner(System.in);
    Function c = new Function();
    System.out.print(c.FirstReverse(s.nextLine()));
  }  
 
}   

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução