STASHFIN Off-Campus OA (2024) | Count Operations to Obtain Zero
Question · Posted Jun 2026
Problem Statement You are given two non-negative integers num1 and num2. In one operation: If num1 >= num2, subtract num2 from num1. Otherwise, subtract num1 from num2. Continue performing operations until either num1 or num2 becomes 0. Return the total number of operations performed. Example Input num1 = 2 num2 = 3 Output 3 Explanation (2,3) → (2,1) Operation 1 (2,1) → (1,1) Operation 2 (1,1) → (0,1) Operation 3 One number becomes zero, so the answer ...
The full answer & interview discussion are available to premium members.
Log in Create a free account