Frage im Vorstellungsgespräch bei UKG

Reverse a string using recursion

Antwort im Vorstellungsgespräch

Anonym

30. März 2022

fairly simple assuming we are only ask to print the reverse string and not return the reverse string: public static void reverseString(String str){ if(str.length() == 0) return; if(str.length() == 1) System.out.println(str); else{ System.out.print(str.charAt(str.length() - 1); reverseString(str.substring(0, str.length() - 1); } }

1