Algorithm · Capital One · Medium
Requirements You receive a character array arr containing only A and P, together with an integer named replacement_rate. During each round, perform one—and only one—of the following actions, checking them in this order: When the suffix made of consecutive P values has length at least replacement_rate, delete exactly replacement_rate P values from that suffix. Otherwise, if an A remains anywhere in the array, change the furthest-right A into a P. If neither action can be…
Checking your access…