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 a given string is sum-string
- Minimum rotations required to get the same string
- Calculate maximum value using '+' or '*' sign between two numbers in a string
- Extract maximum numeric value from a given string | Set 2 (Regex approach)
- Count Uppercase, Lowercase, special character and numeric values
- Smallest window that contains all characters of string itself
- Number of substrings divisible by 6 in a string of integers
- Check if a large number is divisible by 4 or not
- Difference of two large numbers
- Check if a large number is divisible by 11 or not
- Find k'th character of decrypted string
- Calculate sum of all numbers present in a string
- Find the maximum subarray XOR in a given array
- Karatsuba algorithm for fast multiplication using Divide and Conquer algorithm
- Find the smallest window in a string containing all characters of another string
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.