Question: Please answer in Java An Lead square is defined to be an array which satisfies the following conditions. 1. All elements are positive numbers. 2.

Please answer in Java

An Lead square is defined to be an array which satisfies the following conditions.

1. All elements are positive numbers.

2. At least three odd elements are immediately followed by its square.

Examples

{4,9,81,7,49,5,24,3,9} is a lead Square array because the three odd numbers 9,7, and 3 are immediately followed by their squares (81,49,9) respectively.

{9,4,81,7,49,5,24,3,9} is a lead Square array because only two odd numbers 7, and 3 are immediately followed by their squares

{3,9,4,9,3,2,5,25} is not a lead Square array because only two odd numbers are immediately followed by their squares.

{2,4,9,3,15,21} is not a lead Square array because none of the odd numbers are immediately followed by its squares.

Write a method called IsLeadSquareArray which takes an array of integers and returns true if it's a lead square array. otherwise returns false.

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!