Question: 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

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 lines

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!