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.
There's no need for the array to contain 10^7 elements. The string can be at most 10^5 characters long, so the maximum possible uniform substring weight is 10^5 * 26 (a string of 100000 'z's). So you can size the array to 2600000 elements and add a simple check (xi must be less than 2600001).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Weighted Uniform Strings
You are viewing a single comment's thread. Return to all comments →
There's no need for the array to contain 10^7 elements. The string can be at most 10^5 characters long, so the maximum possible uniform substring weight is 10^5 * 26 (a string of 100000 'z's). So you can size the array to 2600000 elements and add a simple check (xi must be less than 2600001).