Wednesday, September 27th
Tape compression Following a compression scheme for a string, where a letter is added to the string and a number signifies copies of the entire string, return the kth letter of the decoded string Brute force is a straight forward approach, but times out for larger encodings A key observation for an efficient solution is that for a string of length n multiplied any number of times, and an index k, the output letter will be the same as k%n With this in mind, we can work backwards to find the answer To work backwards, we first find the size of the string at the end of the problem. Iterate over the input string, if a character is a letter increase the size by 1, otherwise if it's a digit, multiply the length by the digit amount string decodeAtIndex ( string S , int K ) { long totalsize = 0 ; int n = s . size (); for ( int i = 0 ; i < n; ++i) { if ( isdigit ( s [i])) totalsiz...