Answered step by step
Verified Expert Solution
Question
1 Approved Answer
codility ou are given an implementation of a function: classSolution{publicboolsolution(int[]A,intK);} his function, given a non-empty array A of N integers (sorted in nonlecreasing order) and
codility
ou are given an implementation of a function: classSolution{publicboolsolution(int[]A,intK);} his function, given a non-empty array A of N integers (sorted in nonlecreasing order) and integer K, checks whether A contains numbers 1,2,, (every number from 1 to K at least once) and no other numbers. For example, given the following array A, and K=3 : A[]=1A[1]=1A[2]=2A[3]=3A[4]=3 The function should return true. For the following array A, and K=2 : A[]=1A[1]=1A[2]=3 the function should return false. The attached code is still incorrect for some inputs. Despite the error(s), the code may produce a correct answer for the example test cases. The goal of the exercise is to find and fix the bug(s) in the implementation. You can modify at most two linesStep 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