w3resource

Array Coding Problems: Classic & Challenging Challenges

Array Coding Problems: Classic & Challenging Challenges

Here's a list of 30 classic and challenging Data Structures & Algorithms problems from simpler to more advanced and complex ones.

1. Two Sum:

Given an array of integers, find two numbers such that they add up to a specific target.

2. Remove Duplicates from a Sorted Array:

Given a sorted array, remove duplicates in-place, and return the new length.

3. Rotate Array:

Rotate an array to the right by k steps.

4. Product of Array Except Self:

Given an array of nums, return an array of output such that output[i] is equal to the product of all elements except nums[i].

5. Find the Missing Number:

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one missing from the array.

6.Trapping Rain Water:

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

7. Container With Most Water:

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai), n vertical lines are drawn such that the two endpoints of the line i are at (i, ai) and (i, 0). Find two lines that, together with the x-axis, form a container containing the most water.

8. Max Subarray Sum (Kadane's Algorithm):

Find the contiguous subarray with the largest sum.

9. Merge Intervals:

Given a collection of intervals, merge any overlapping intervals.

10. Search in a Rotated Sorted Array:

Search for a target value in a rotated sorted array.

11. Rotate Image:

Rotate an n x n matrix clockwise.

12. Find Peak Element:

Find a peak element in an array. A peak element is an element greater than or equal to its neighbors.

13. Minimum Size Subarray Sum:

Given an array of positive integers and a target value, find the minimum length of a contiguous subarray whose sum is greater than or equal to the target.

14. Pascal's Triangle:

Generate the first n rows of Pascal's triangle.

15. Next Permutation:

Implement the next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.

16. Valid Sudoku:

Determine if a 9x9 Sudoku board is valid.

17. Combination Sum:

Given a set of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to the target.

18. Majority Element:

Given an array of size n, find the majority element.

19. Spiral Matrix:

Given an m x n matrix, return all matrix elements in spiral order.

20. Sort Colors (Dutch National Flag Algorithm):

Given an array with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order of red, white, and blue.

21. Median of Two Sorted Arrays:

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays.

22. Set Matrix Zeroes:

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

23. Jump Game:

Given an array of non-negative integers, you are initially positioned at the first index, and each element in the array represents your maximum jump length. Check if the last index is reachable.

24. First Missing Positive:

Given an unsorted integer array, find the smallest missing positive integer.

25. Kth Largest Element in an Array:

Find the kth largest element in an unsorted array.

26. Word Search:

Given a 2D board and a word, find out if it exists on the grid.

27. Subarray Sum Equals K:

Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals k.

28. Combination Sum II:

Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations of candidates where the candidate numbers sum to the target.

29. Sort Colors:

Given an array with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order of red, white, and blue.

30. Pascal's Triangle II:

Given an index k, return the kth row of Pascal's triangle.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/data-structures-and-algorithms/array/array-data-structure-coding-problems.php