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
- Maximize the given number by replacing a segment of digits with the alternate digits given
- Longest Common Extension / LCE | Set 3 (Segment Tree Method)
- Concatenate strings in any order to get Maximum Number of "AB"
- Maximum number of removals of given subsequence from a string
- Number of subarrays with maximum values in given range
- Maximum sum and product of the M consecutive digits in a number
- Find the maximum possible Binary Number from given string
- String with maximum number of unique characters
- Maximum number of characters between any two same character in a string
- Maximum number of given operations to remove the entire string
- Find the number in a range having maximum product of the digits
- Maximum number of Unique integers in Sub-Array of given size
- Queries to print the character that occurs the maximum number of times in a given range
- Permutation of a string with maximum number of characters greater than its adjacent characters
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.
Improved By : PranchalKatiyar