Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,333 views

in Online Assessments by Expert (108,100 points) | 1,333 views

1 Answer

0 like 0 dislike
Best answer
Problem:
Given array of positive integers of length n (n<=100000)

(a[i]<=100000)
You have to maximize the consecutive integers count in array (Order doesn't matter)
Only operation you are allowed to with array elements is to make
ai=ai+1 i.e increase the element by one  OR
ai=ai+0 i.e do nothing with element
for all 0<=i<n
E.gInput
n=9
arr:1 1 3 4 6 6 6 8 10
ans = 5
Explanation:
You can transform the array to
1 1 4 5 6 7 6 8 10
maximum consecutive length is 5 with elements 4,5,6,7,8.
by Expert (108,100 points)
edited by

Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .