Geeksforgeeks

Error

×

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 | |

Handle | Score |

@avaiesshaik782 | 786 |

@arpitsatnalika | 777 |

@tujhekya | 602 |

@prakharxyz | 601 |

@code_it_ | 591 |

@iamronak | 505 |

@imnm | 500 |

@pradeepkumarjad | 488 |

@satyam0460 | 481 |

@nitesha125 | 480 |

@Rahul Jadhav 1 | 466 |

Complete Leaderboard |

Given an integer **N** denoting the Length of a line segment. You need to cut the line segment in such a way that the cut length of a line segment each time is either **x** , **y** or **z**. Here x, y, and z are integers.

After performing all the cut operations, your** total number of cut segments must be maximum**.

**Example 1:**

Input:N = 4 x = 2, y = 1, z = 1Output:4Explanation:Total length is 4, and the cut lengths are 2, 1 and 1. We can make maximum 4 segments each of length 1.

**Example 2:**

Input:N = 5 x = 5, y = 3, z = 2Output:2Explanation:Here total length is 5, and the cut lengths are 5, 3 and 2. We can make two segments of lengths 3 and 2.

**Your Task:**

You only need to complete the function **maximizeTheCuts() **that takes n, x, y, z as parameters and returns **max number cuts**.

**Expected Time Complexity** : O(N)

**Expected Auxiliary Space**: O(N)

**Constraints**

1 <= N, x, y, z <= 10^{4}

Login 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?

Yes
Maximize The Cut Segments

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.