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.
Check out this portion of the problem statement (Input and Constraints)
Note this constraint:
0 <= x <= 10^7
10e7 is just another way to represent 10^7.
Now coming to what I was trying to accomplish with the vector:
The boolean vector has 10e7 indices.
Let us take each index location of this vector to represent the corresponding weight of substring.
ie,
If Index 5 of the vector is TRUE, then it means there is a substring of weight 5 somewhere in the string.
If Index 100765 of the vector is TRUE, then it means there is a substring of weight 100765 somewhere in the string.
If Index 153 remains false after running through the loop, it means there is no substring of weight 153 in the given string.
The constraints mentions that the string weight is in the range of 0 to 10e7.
Hence the maximum possible weight that we would need to keep track of is 10e7.
That's why I sized the vector to 10e7.
Sorry for the delay in clarifying...
Hope you understood :)
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 →
Check out this portion of the problem statement (Input and Constraints)
Note this constraint:
0 <= x <= 10^7
10e7 is just another way to represent 10^7.
Now coming to what I was trying to accomplish with the vector:
The boolean vector has 10e7 indices. Let us take each index location of this vector to represent the corresponding weight of substring.
ie, If Index 5 of the vector is TRUE, then it means there is a substring of weight 5 somewhere in the string. If Index 100765 of the vector is TRUE, then it means there is a substring of weight 100765 somewhere in the string. If Index 153 remains false after running through the loop, it means there is no substring of weight 153 in the given string.
The constraints mentions that the string weight is in the range of 0 to 10e7. Hence the maximum possible weight that we would need to keep track of is 10e7. That's why I sized the vector to 10e7.
Sorry for the delay in clarifying... Hope you understood :)