Company: hire.glider.ai
Difficulty: medium
Paint the Building Problem Description There is a multistory building with N floors, numbered from 1 (the ground floor) to N (the top floor). Some floors are already painted and some are not. A painter, Ricky , must paint every unpainted floor. To paint a floor Ricky must be standing on it; the act of painting itself takes no movement. Ricky starts on the ground floor (floor 1 ). A single movement is one of the following: Walk from the current floor to the next floor ( +1 ) or to the previous floor ( -1 ). This counts as one movement. Ricky can never go below floor 1 or above floor N . Step from the current floor into the lift (this counts as one movement) and later step out of the lift onto any floor (this counts as one more movement). So a single lift ride costs exactly two movements and can take Ricky from any floor to any other floor. Help Ricky determine the minimum total number of movements needed so that he has visited — and therefore painted — every unpainted floor. Input The f