Given a circular array of size n, find the maximum subarray sum of the non-empty subarray. Examples: Input: arr[] = {8, -8, 9, -9, 10,… Read More
Category Archives: Data Structures
Two of the nodes of a Binary Search Tree (BST) are swapped. Fix (or correct) the BST. Input: x = 20, y = 8 … Read More
Given a binary tree, print boundary nodes of the binary tree Anti-Clockwise starting from the root. The boundary includes left boundary (nodes on left excluding… Read More
Given a number, find the next smallest palindrome larger than this number. For example, if the input number is “2 3 5 4 5”, the… Read More
Given an array of N elements, where each element is at most K away from its target position, devise an algorithm that sorts in O(N… Read More
Given a Binary Tree, write a function to check whether the given Binary Tree is Complete Binary Tree or not.A complete binary tree is a… Read More
Given an array of integers, find anyone combination of four elements in the array whose sum is equal to a given value X. For example, … Read More
Given an array of integers, find all combination of four elements in the array whose sum is equal to a given value X. For example, if… Read More
Given an array of integers, replace every element with the next greatest element (greatest element on the right side) in the array. Since there is… Read More
Given a singly linked list, The task is to rotate the linked list counter-clockwise by k nodes. Examples: Input: linked list = 10->20->30->40->50->60, k =… Read More
Given Preorder traversal of a BST, check if each non-leaf node has only one child. Assume that the BST contains unique entries. Examples : Input: pre[]… Read More
Given three linked lists, say a, b and c, find one node from each list such that the sum of the values of the nodes… Read More
Given an array ‘pre[]’ that represents Preorder traversal of a special binary tree where every node has either 0 or 2 children. One more array… Read More
A magic square of order n is an arrangement of n2 numbers, usually distinct integers, in a square, such that the n numbers in all… Read More
Given an array that contains both positive and negative integers, find the product of the maximum product subarray. Examples: Input: arr[] = {6, -3, -10,… Read More