Question: java8 Everyone has a favorite number. Jacob's favorite number is and Jayden's favorite number is Y. A non-empty array A consisting of N integers is


java8
Everyone has a favorite number. Jacob's favorite number is and Jayden's favorite number is Y. A non-empty array A consisting of N integers is given. Jacob and Jayden are interested in occurrences of their favorite numbers X and Y in array A. They are looking for the longest leading fragment (prefix) of array A in which there is an equal number of occurrences of X and Y. More formally, they are looking for the largest P, such that 0P
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
