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

asked on

sameEnds challenge

Hi,

I am working on below challenge

http://codingbat.com/prob/p131516

I am not clear on challenge desciption and  how to approach. please advise
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore 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
We won't (and are not allowed to) write the code for you.
At least come up with some code you wrote yourself.
Starting from that we can (try to) help you further.
Avatar of gudii9

ASKER

public String sameEnds(String string) {
    String result = "";
    int len = string.length();
    for (int i = 0; i <= len / 2; i++)
        for (int j = len / 2; j < len; j++)
            if (string.substring(0, i).equals(string.substring(j)))
                result = string.substring(0, i);
    return result;
}

above worked fine