0% found this document useful (0 votes)
40 views

Chat GPT

The document lists 20 array problems including finding the sum and average of an array, largest and smallest elements, reversing an array, rotating an array, finding duplicate elements, missing number, searching in a rotated sorted array, two sum, product of array except self, maximum subarray sum, merging two sorted arrays, finding the kth largest element, finding the minimum size subarray sum, finding the majority element, trapping rainwater, spiral matrix, matrix rotation, setting matrix zeroes, finding the peak element, and finding the longest consecutive sequence.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Chat GPT

The document lists 20 array problems including finding the sum and average of an array, largest and smallest elements, reversing an array, rotating an array, finding duplicate elements, missing number, searching in a rotated sorted array, two sum, product of array except self, maximum subarray sum, merging two sorted arrays, finding the kth largest element, finding the minimum size subarray sum, finding the majority element, trapping rainwater, spiral matrix, matrix rotation, setting matrix zeroes, finding the peak element, and finding the longest consecutive sequence.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ChatGPT

chat.openai.com/c/5ac1c417-6c59-42ea-9cea-519a46c64712

1. Array Sum and Average:

Write a program to find the sum and average of elements in an integer array.
2. Largest and Smallest Element:

Find the largest and smallest elements in an array.


3. Reverse an Array:

Reverse the elements in an array without using additional data structures.


4. Array Rotation:

Given an array, rotate it to the right by 'k' steps.


5. Duplicate Elements:

Find and remove duplicate elements in an array.


6. Missing Number:

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one
that is missing.
7. Search in a Rotated Sorted Array:

Given a sorted and rotated array, write a program to find a target element.
8. Two Sum:

Given an array of integers, find two numbers such that they add up to a specific
target sum.
9. Product of Array Except Self:

Given an array, return an array output where each element is the product of all
elements in the array except itself.
10. Max Subarray Sum:

Find the contiguous subarray with the largest sum in an array.


11. Merge Two Sorted Arrays:

Given two sorted arrays, merge them into a single sorted array.
12. Kth Largest Element:

Find the kth largest element in an unsorted array.

1/2
13. Minimum Size Subarray Sum:

Find the minimum length of a contiguous subarray that sums to a target value.
14. Majority Element:

Find the majority element in an array (element that appears more than n/2 times).
15. Trapping Rainwater:

Given an array representing the height of walls, calculate how much rainwater
can be trapped.
16. Spiral Matrix:

Generate a spiral order traversal of a given matrix.


17. Matrix Rotation:

Rotate a given matrix (NxN) by 90 degrees.


18. Set Matrix Zeroes:

Given an m x n matrix, if an element is 0, set its entire row and column to 0.


19. Find Peak Element:

Find the peak element in an array (an element greater than its neighbors).
20. Longest Consecutive Sequence:

Find the length of the longest consecutive elements sequence in an unsorted


array.

Remember to practice these problems and understand the time and space complexities of
your solutions. This will not only help you in interviews but also improve your problem-solving
skills and understanding of arrays in Java.

2/2

You might also like