Hey, in the example 5 is also considered as a cb number, but 5 is divisible by 5 in the specified numbers. So, how can it be a cb number?
Also, could you please help me with my code. Link to that is:
Here, i have used 2d array to loop through all the possible subarrays, if the subarray is giving a cb number, i am adding its starting and ending indices to a vector. Finally, this problem gets simplified to somewhat similar problem as the job scheduling algorithm. And then in that way i am able to calculate the subset with amx number of non-overlapping elements. This solution is working correctly for my self generated cases, but when i am submitting , it is only passing for one test case and showing wrong answer for others. Please help me here.
Problem with example and help with solution
Hi @Akhil098
Conditions are : 0 and 1 are not a CB number.
2,3,5,7,11,13,17,19,23,29 are CB numbers.
Any number not divisible by the numbers in point 2( Given above) are also CB numbers.
So all other numbers which are not divisible by above 10 numbers are cb numbers. But above 10 numbers are explicitly given as cb numbers.
Corrected Link : https://ide.codingblocks.com/s/202755
Hope it helps.