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

asked on

zip zap java cchallenge

Hi,
I am working on below challenge
http://codingbat.com/prob/p180759
I tried my code as below
public String zipZap(String str) {

String str2= str.replaceAll("z.p","zp");
  return str2;
  
 
 
 
}

Open in new window

I am getting below result
Expected      Run            
zipZap("zipXzap") → "zpXzp"      "zpXzp"      OK         
zipZap("zopzop") → "zpzp"      "zpzp"      OK         
zipZap("zzzopzop") → "zzzpzp"      "zzzpzp"      OK         
zipZap("zibzap") → "zibzp"      "zibzp"      OK         
zipZap("zip") → "zp"      "zp"      OK         
zipZap("zi") → "zi"      "zi"      OK         
zipZap("z") → "z"      "z"      OK         
zipZap("") → ""      ""      OK         
zipZap("zzp") → "zp"      "zp"      OK         
zipZap("abcppp") → "abcppp"      "abcppp"      OK         
zipZap("azbcppp") → "azbcppp"      "azbcppp"      OK         
zipZap("azbcpzpp") → "azbcpzp"      "azbcpzp"      OK         
other tests
OK         

how to  improve my approach, results and design of this challenge. How do i make a graphical venn or flow chart or some other relevant diagram to design it before writing code to decide best strategy?
 Please advise
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America 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
how to  improve my approach
What could possibly be improved on one line of code?
Really?
Eliminating an obsolete variable was the answer you were looking for?
Ridiculous.