← Questions
Penalty for shutting down a server from its uptime log
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A server's log has one entry per hour, 0 when it was up and 1 when it was down, separated by spaces. If the server is removed just before hour k, the penalty is the number of hours it was down while still installed plus the number of hours it would have been up after removal. Given the log and k, return the penalty. Handle k at either end of the log and explain how prefix counts let you evaluate any k in constant time.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
