Greedy
Simulation: 860 Lemonade Change (N) Simply simulate each customer buy and change process by looping over each bill in the bills array and handle 3 cases: bill == 5, 10 and 20. Must greedily use $10 first before using $5 when do change for $20. 874 Walking Robot Simulation (Y) We simulate the path of the robot step by step ( d is direction): For each cmd in the commands array do the following: (cmd == -1) : d = (d + 1) % 4; (cmd == -2) : d = (d + 3) % 4; Otherwise: (move steps) while (cmd-- > 0 && !hashSet.count(make_pair(x + dirs[d][0], y + dirs[d][1]))) x += dirs[d][0]; y += dirs[d][1...