-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Arrays
Mission Peace edited this page Nov 5, 2016
·
12 revisions
- Given two numbers in form of array add them - ArrayAddition.java
- Given stock prices for number of days BuySellStockProfit.java
- Buy sell stock once to maximize profit
- Buy sell stocks any number of times to maximum profit
- Given an array of elements check if elements in the array are consecutive or not. - CheckIfArrayElementsAreConsecutive.java
- Write a function to determine if array contains duplicate elements within k distance from each other - DuplicateWithinkIndices.java
- Given an array and a number k < n, find all elements occurring more than n by k times - FindElementsOccurringNByKTimesTetris.java
- Given a list of gas stations and amount of fuel they have, find a tour which travels all gas stations - GasStationCircle.java
- Given an unordered array of positive integers, create an algorithm that makes sure no group of integers of size bigger than M have the same integers - GroupElementsInSizeM.java
- Given an array find an increasing subsequence of length 3 which has maximum product - IncreasingSubsequnceOfLength3WithMaxProduct.java
- Given an array find maximum circular contiguous sum - KadaneWrapArray.java
- kth largest element in an unsorted array using quick select - KthElementInArray.java
- kth largest element in two sorted array - KthLargestInTwoSortedArray.java
- Print next greater element for every element in array - LargerElementOnRight.java
- Given an array of 0s and 1s find the largest subarray with equal number of 0s and 1s - LargestSubArrayWithEqual0sAnd1s.java
- Longest increasing subsequence in an array with O(NlogN) time complexity - LongestIncreasingSubSequenceOlogNMethod.java
- Given an array maximize i - j such that a[i] > a[j] - MaximumIminusJSuchThatAiGTAj.java
- Given an array, find maximum of all subarrays of size k - MaximumOfSubarrayOfSizeK.java
- Given an array of positive and negative numbers, find a subarray which has maximum product - MaxProductSubarray.java maxproductsubarray.py
- Given an array of size n, the array contains numbers in range from 0 to k-1 where k is a positive integer and k <= n. Find the maximum repeating number in this array - MaxRepeatingNumber.java
- Given an array and two numbers, find minimum distance between these numbers. There could duplicates of these numbers in array - MinimumDistanceBetweenTwoNumbers.java
- Find minimum length unsorted subarray, sorting which makes entire array sorted - MinimumSortedWhichSortsEntireArray.java
- Given array of 0 and non zero numbers, move all 0s to the end in O(n) time - MoveAllZerosToEnd.java
- Given an array, return a new array which has multiplication of all elements except own index - MultiplyAllFieldsExceptOwnPosition.java
- Given an unsorted array, find total number of triangles formed taking 3 elements of this array - NumberOfTrianglesInUnsortedArray.java numberoftrianglesunsortedarray.py
- Given an array with first negative and then positive numbers, position negative and positive numbers alternately - PositiveAndNegativeNumberAlternatively.java
- Given an array arr[] of size n where every element is in range from 0 to n-1. Rearrange the given array so that arr[i] becomes arr[arr[i]] in O(n) time and O(1) space - RearrangeSuchThatArriBecomesArrArri.java
- Given an array with elements in range of 0 to n-1, one number is repeated and one number is missing. Find both the numbers - RepeatingAndMissingNumber.java
- Stable marriage problem - StableMarriageProblem.java
- Given an unsorted array of nonnegative numbers , find a contiguous subarray with given sum - SubarrayWithGivenSum.java
- Given an array, find triplet which sums to a given value - https://github.com/mission-peace/interview/blob/master/src/com/interview/array/TripletInArray.java
- Given a set of n integers, divide the set in two subsets of n/2 sizes each such that the difference of the sum of two subsets is as minimum as possible - TugOfWar.java
- Given an unsorted array convert it into a < b > c < d > e < f > g fashion - ConvertAnArrayIntoDecreaseIncreaseFashion.java
- Given multiple sorted lists, sort them into one list - ChunkMerge.java
- Given an array which represents bars how much rain water will be trapped - TrappingWater.java
- Print nth number of count sequence. Sequence is like 1 11 21 1211 111221 and so on. NthElementOfCountNumberSequence.java
- Given 2 arrays of same length consisting of 0s and 1s find max span i,j in two arrays such that sum b/w i to j is same. LongestSameSumSpan.java longestsamesumspan.py
- Count number of inversions where i < j < k and input[i] > input[j] > input[k] in array. CountInversionOfSize3.java countinversionofsize3.py
- Given an array of unique integers and total, find all triplets whose sum is less than total. TripletSumLessThanTotal.java tripletsumlessthantotal.py
- Given array of 0s and 1s and maximum flip allowed from 0 to 1, find maximum number of consecutive 1s you can have in array. Flip0sMaximum1s.java flip0smaximum1s.py
- Given two arrays, arrange elements of first element by values in second array. ReorderArrayByIndex.java reorderarraybyindex.py
- Given an array find which rotation will give max sum of i*arr[i] - RotationWithMaxSum.java rotationwithmaxsum.py
- Zig zag arrangement of array. ZigZagArrangement.java zigzagarrangement.py
- Rearrange array with elements in range 0 to n-1 such that arr[i] = j becomes arr[j] = i. RearrangeArrayPerIndex.java rearrangearrayperindex.py
- Given sorted array of positive integers find smallest positive integer not represented by sum of some subset of this array. SmallestIntegerNotRepresentedBySubsetSum.java smallestintegernotrepresentedbysubsetsum.py
- Arrange positive and negative numbers alternatively maintaining order in input array. PositiveAndNegativeNumberAlternativelyMaintainingOrder.java positiveandnegativealternativelymaintainingorder.py
- Given two sorted arrays find max sum path from start of any array to end of any array. Switch only happens at common array element. MaximumSumPathTwoArrays.java maximumsumpathtwoarrays.py
- Find common elements in 3 sorted array. CommonThreeSortedArray.java commonthreesortedarray.py
- Generate minimum number from give sequence of D and I where D indicates decrease and I indicates increase.[MinimumNumberFromSequence.java] (https://github.com/mission-peace/interview/blob/master/src/com/interview/array/MinimumNumberFromSequence.java)
- Count smaller numbers on right side of every element in given array - CountSmallerOnRight.java
- Find max array created by picking k elements from array1 and array2 by maintaining order in both the arrays - MaxNumberFromTwoArray
- Find duplicate in array of size n + 1 with elements from 1 to n in O(1) space - DuplicateNumberDetection.java
- Shortest palindrome from a string - ShortestPalindrome.java
- Find if there exists an increasing subsequence of length 3 or increasing triplet -IncreasingTripletSubsequence.java
- Given an unsorted array find maximum gap between consecutive element in sorted array - MaximumGap.java
- Find longest consecutive subsequence in an unsorted array - LongestConsecutiveSubsequence.java
- Wiggle sort - WiggleSort.java
- Best meeting point from bunch of people - BestMeetingPoint.java
- Given an array of positive number arrange it in max min fashion - MaximumMinimumArrangement.java
- Given a string find if it can form additive number - AdditiveNumber.java
- Minimum number of meeting rooms needed to schedule array of meetings - MeetingRooms.java
- Four sum in array equal to given target - FourSum.java
- Determine if you can reach end of array. You can jump as much as value at every position of array - JumpGame.java
- Given a sorted array of integers nums and integer values a, b and c. Apply a function of the form f(x) = ax2 + bx + c to each element x in the array - SortedArrayTransformation.java
- Find missing ranges in sorted array - MissingRanges.java
- Given a sorted integer array without duplicates, return the summary of its ranges - SummaryRanges.java