when two arrays are given and you have to find whether they are consecutive or not
Answers
Answered by
1
Answer:
Find minimum and maximum element in the array.
Check if max-min+1==n, if elements are consecutive then this condition should meet.
Create a visited boolean array.
Iterate over the array and check. visited[arr[i]-min] is true, then return false as elements are repeated. mark the element visited.
Similar questions