Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers that has the largest sum....
Given a linked list, write a function to reverse every k nodes (where k is an input to the function)....
Given two positive integers L and R, the task is to count the total number of set bits in the binary representation of all the numbers from L to R....
Given two unsorted Linked List, the task is to merge them to get a sorted singly linked list.Examples:...
Rahul and Ankit are the only two waiters in the Royal Restaurant. Today, the restaurant received N orders. The amount of tips may differ when handled by different waiters and given as arrays A[] and B[] such that if Rahul takes the ith Order, he would be tipped A[i] rupees, and if Ankit takes this order, the tip would be B[i] rupees....
Given an array of strings Q[], consisting of queries of the following types:...
Given a grid mat[][] of size M * N, consisting of only 0s, 1s, and 2s, where 0 represents empty place, 1 represents a person and 2 represents the fire, the task is to count the minimum number of moves required such that the person comes out from the grid safely. In each step, the fire will burn its side-adjacent cells and the person will move from the current cell to one of its side-adjacent cells. If it is not possible to come out from the grid, then print -1....
Given an array arr[] of size N. The task is to find the sum of the contiguous subarray within a arr[] with the largest sum....
Given an array A[] of n numbers and another number x, the task is to check whether or not there exist two elements in A[] whose sum is exactly x....
Given a string S and an integer K, the task is to generate lexicographically the largest string possible from the given string, by removing characters also, that consist of at most K consecutive similar characters....
Given two Binary Trees, write a function that returns true if two trees are mirror of each other, else false. For example, the function should return true for following input trees....
Given a linked list, write a function to reverse every k nodes (where k is an input to the function)....