Given a large number as string s and an integer k which denotes the number of breakpoints we must put in the number k <= string length. The task is to find maximum segment value after putting exactly k breakpoints.
Input : s = "8754", k = 2 Output : Maximum number = 87 Explanation : We need to two breakpoints. After putting the breakpoints, we get following options 8 75 4 87 5 4 The maximum segment value is 87. Input : s = "999", k = 1 Output : Maximum Segment Value = 99 Explanation : We need to one breakpoint. After putting the breakpoint, we either get 99,9 or 9,99.
One important observation is, the maximum would always be of length “string-length – k” which is the maximum value of any segment. Considering the fact, problem becomes like sliding window problem means we need to find maximum of all substrings of size (string-length – k).
Maximum number = 87
- Check if number can be displayed using seven segment led
- Longest Common Extension / LCE | Set 3 (Segment Tree Method)
- Maximum number of removals of given subsequence from a string
- String with maximum number of unique characters
- Maximum sum and product of the M consecutive digits in a number
- Maximum number of characters between any two same character in a string
- Number of subarrays with maximum values in given range
- Maximum number of Unique integers in Sub-Array of given size
- Find the number in a range having maximum product of the digits
- Sliding Window Maximum (Maximum of all subarrays of size k)
- Permutation of a string with maximum number of characters greater than its adjacent characters
- Maximum sum subarray having sum less than or equal to given sum
- Maximum of all Subarrays of size k using set in C++ STL
- Maximum length of segments of 0's and 1's
- Maximum length subsequence possible of the form R^N K^N
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.