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.
i is used because it brings the pointer to the beginning of the string .The checking for similar alphabet has to be done with a character whose index is 1 with a character whose index is 0.
If 'i=0' is avoided then we do not get an efficient solution as it starts printing the duplicate letters as it is.
Hope it helps!
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 →
i is used because it brings the pointer to the beginning of the string .The checking for similar alphabet has to be done with a character whose index is 1 with a character whose index is 0. If 'i=0' is avoided then we do not get an efficient solution as it starts printing the duplicate letters as it is. Hope it helps!