Given a string, print all permutations of it in sorted order. For example, if the input string is “ABC”, then output should be “ABC, ACB,… Read More
Category Archives: Data Structures
Given a string str, find its rank among all its permutations when sorted lexicographically. Note: The characters a string are all unique. Examples: Input: str… Read More
Given two arrays that represent preorder and postorder traversals of a full binary tree, construct the binary tree. Full Binary Tree is a binary tree… Read More
Given an array where every element occurs three times, except one element which occurs only once. Find the element that occurs once. The expected… Read More
Given an array of non-negative integers. Find the largest multiple of 3 that can be formed from array elements. For example, if the input array is… Read More
Given a linked list where every node represents a linked list and contains two pointers of its type: Pointer to next node in the main… Read More
Given a binary matrix, print all unique rows of the given matrix. Example: Input: {0, 1, 0, 0, 1} {1, 0, 1, 1, 0} {0,… Read More
Given N machines. Each machine contains some numbers in sorted form. But the amount of numbers, each machine has is not fixed. Output the numbers… Read More
Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s. Example: Input matrix : 0 1… Read More
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