You are on page 1of 2

OOPs Assignment on Arrays

1.
Find whether the largest element in the array is at least twice as much as every
other number in the array.
If it is, return the index of the largest element, otherwise return -1.
Example 1:

Input: nums = [3, 6, 1, 0]


Output: 1
Explanation: 6 is the largest integer, and for every other number in the array x,
6 is more than twice as big as x. The index of value 6 is 1, so we return 1.

Example 2:

Input: nums = [1, 2, 3, 4]


Output: -1
Explanation: 4 isn't at least as big as twice the value of 3, so we return -1.

2.

Given an unsorted array of integers, find the length of


Longest continuous increasing subsequence (subarray).
Example 1:

Input: [1,3,5,4,7]
Output: 3
Explanation: The longest continuous increasing subsequence is [1,3,5], its length
is 3.
Even though [1,3,5,7] is also an increasing subsequence, it's not a continuous one
where 5 and 7 are separated by 4.

Example 2:

Input: [2,2,2,2,2]
Output: 1
Explanation: The longest continuous increasing subsequence is [2], its length is 1.

3.

Given an unsorted array of integers, find the length of the longest consecutive
elements sequence.
For example,
Given [100, 4, 200, 1, 3, 2],
The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.

4. write a java program Find the third largest number in the given array?
5. Write a java program to remove the given element from the array?
6. Write a java program to find minimum and maximum elements from the array?

You might also like