Generate random input from an array according to given probabilities
Write an algorithm to generate any one of the given n numbers according to given probabilities.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedWrite an algorithm to generate any one of the given n numbers according to given probabilities.
Given a sorted integer array, find a pair in it having an absolute minimum sum.
Given two sorted integer arrays, merge them into a single array in decreasing order, and return it. In other words, merge two sorted arrays from their end.
Given two integer arrays, each of which is sorted in increasing order, merge them into a single array in increasing order, and return it.
Given an integer array, find the index of the maximum occurring element with an equal probability.
Given an integer array, check if only consecutive integers form the array.
Given an array of n integers where every element appears an even number of times except one element, which appears an odd number of times, find that odd occurring element in logarithmic time and constant space.
Given an unsorted integer array, find two non-overlapping pairs in it having the same sum.
Find the minimum number of moves required for converting an array of zeros to a given array using only increment and double operations. The increment operation increases the value of an array element by 1. And the double operation doubles the value of each array element.
This post will discuss how to reverse an array in C++.
In this post, we will see how to right-rotate an array by specified positions. For example, right rotating array { 1, 2, 3, 4, 5, 6, 7 } three times will result in array { 5, 6, 7, 1, 2, 3, 4 }.
In this post, we will see how to left-rotate an array by specified positions. For example, left-rotating array { 1, 2, 3, 4, 5 } twice results in array { 3, 4, 5, 1, 2 }.