Handle Score
@Ibrahim Nash 6454
@blackshadows 6380
@mb1973 5718
@Quandray 5245
@akhayrutdinov 5111
@saiujwal13083 5046
@sanjay05 3762
@kirtidee18 3709
@mantu_singh 3556
@marius_valentin_dragoi 3523
@sushant_a 3459
Complete Leaderboard
Min cut Square
Medium Accuracy: 42.17% Submissions: 603 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
3 (squares of size 12x12) + 
2 (squares of size 18x18)

Example 2:

Input: M = 4, N = 5
Output: 5
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)

1 ≤ M, N ≤ 102

to report an issue on this page.


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


All Submissions

My Submissions:

Login to access your submissions.

Min cut Square

Output Window