We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
String java.lang.String.substring(int beginIndex, int endIndex)
Returns a string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Contacts
You are viewing a single comment's thread. Return to all comments →
Well you did code a very intelligent solution, but the above code fails for the following test case:
your output
but expected output according to the question
well instead of
it should be
since,
String java.lang.String.substring(int beginIndex, int endIndex)
Returns a string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.