This assessment evaluates algorithmic proficiency in time-based counting and synchronous string transformation, covering competencies in windowed aggregation, array and binary-string processing, simulation of concurrent swaps, and algorithmic complexity analysis.
This online assessment contained two coding problems:
requestTimes
, where
requestTimes[i]
is the second at which the
i
-th request arrives, and an integer
windowSize
. Return the maximum number of requests that occur within any inclusive time interval of length
windowSize
seconds. In other words, find the largest number of elements that can fit inside some interval
[t, t + windowSize]
.
s
consisting only of
'0'
and
'1'
. Every second, all adjacent occurrences of
'01'
are swapped simultaneously to become
'10'
. Repeat this process until the string no longer contains
'01'
. Return the number of seconds required.
Example: s = "001011" transforms as follows:
001011 -> 010101 -> 101010 -> 110100 -> 111000
So the answer is 4 seconds.