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.
The function substr(x, y) gives us a new string that starts at position x and has a length of y.
Let suppose that we have a string: a = "house",
And we want to take all the string except the first letter, that is "ouse".
Then we have to start at position 1 ('o') and go until the end of the string.
We know that the string "house" has a length of a.size(), therefore the string "ouse" will have a length of a.size()-1.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strings
You are viewing a single comment's thread. Return to all comments →
The function substr(x, y) gives us a new string that starts at position x and has a length of y.
Let suppose that we have a string: a = "house", And we want to take all the string except the first letter, that is "ouse".
Then we have to start at position 1 ('o') and go until the end of the string. We know that the string "house" has a length of a.size(), therefore the string "ouse" will have a length of a.size()-1.