Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

allStar challenge

Hi,

I am working on below challenge.
http://codingbat.com/prob/p183394
Psedo code:
1. check the array length 0  or 1 then retun same str
2.else return string with first character concatenated with * and then rest of characters argument recursion method

I wrote my code as below and passing all tests
public String allStar(String str) {
  if(str.length()==0||str.length()==1){
    return str;
  }
  else{
  return str.charAt(0)+"*"+allStar(str.substring(1));
  }
}

Open in new window


Any improvements or alternate approaches?      

please advise
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial