Leaderboard
Showing:
Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
Min cut Square
Medium Accuracy: 37.32% Submissions: 209 Points: 4

Given two numbers M and N, which represents the length and breadth of a paper, the task is to cut the paper into squares of any size and find the minimum number of squares that can be cut from the paper.

Example 1:

Input: M = 36, N = 30
Output: 5
Explanation: 
3 (squares of size 12x12) + 
2 (squares of size 18x18)

Example 2:

Input: M = 4, N = 5
Output: 5
Explanation: 
1 (squares of size 4x4) + 
4 (squares of size 1x1)


Your Task:  
You don't need to read input or print anything. Complete the function minCut() which takes M and N as input parameters and returns the integer value

Expected Time Complexity: O(M*N)
Expected Auxiliary Space: O(M*N)

Constraints:
1 ≤ M, N ≤ 102

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Min cut Square

Output Window