gudii9
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
Any improvements or alternate approaches?
please advise
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));
}
}
Any improvements or alternate approaches?
please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.