Question
Given a non-negative integer n <999999999999999999 and k, find the length of the longest sub-string T, in which the occurrence of each number is no
Given a non-negative integer n<999999999999999999 and k, find the length of the longest sub-string T, in which the occurrence of each number is no less than k. Here are two examples:
(1). Given n=11122 and k=3, the answer is 3. In this case, the longest string is 111, in which number 1 appears 3 times, which is no less than k=3 times.
(2). Given n=121223 and k=2, the answer is 5. In this case, the longest string is 12122, in which number 1 appears 2 times, and 2 appears 3 times. Both 1 and 2 appears no less than k=2 times. n=223 is another sub-string, but it does not meet the requirement, because 2 only appears one time (less than k=2 times). n=121223 itself is also a sub-string not meeting the requirement: 3 appears only once (less than k=2 times).
Use recursion to find the answer (length of the longest sub-string T), based on the given n and k in c program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started