Given an array of positive and negative numbers, find if there is a subarray (of size at-least one) with 0 sum....
Given an array of numbers, arrange them in a way that yields the largest value. For example, if the given numbers are {54, 546, 548, 60}, the arrangement 6054854654 gives the largest value. And if the given numbers are {1, 34, 3, 98, 9, 76, 45, 4}, then the arrangement 998764543431 gives the largest value....
Given a linked list, write a function to reverse every k nodes (where k is an input to the function). Examples:...
An array contains both positive and negative numbers in random order...
Given an array A[] consisting of only 0s, 1s, and 2s. The task is to sort the array, i.e., put all 0s first, then all 1s and all 2s in last....
Given a string, the task is to reverse the order of the words in the given string....
Given a sorted and rotated array arr[] of size N and a key, the task is to find the key in the array....
Given a string, recursively remove adjacent duplicate characters from the string. The output string should not have any adjacent duplicates. See the following examples....
An array contains both positive and negative numbers in random order...
Example: Let the input string be “i like this program very much”. The function should change the string to “much very program this like i”...
Example: Let the input string be “i like this program very much”. The function should change the string to “much very program this like i”...
Efficient approach: If we are allowed to buy and sell only once, then we can use following algorithm. Maximum difference between two elements. Here we are allowed to buy and sell multiple times. Following is the algorithm for this problem....