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.
because you have specified
s=s.substring(0,i)+s.substring(i+2);
in case when i will be equal to s.length-1 then in that case i+2 will be an out of range value.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
because you have specified s=s.substring(0,i)+s.substring(i+2); in case when i will be equal to s.length-1 then in that case i+2 will be an out of range value.