Algorithms Questions
Algorithms Questions
find the smallest window in string1 containing all the characters in string2 Reverse words in a given string prepare run length encoded string of given input string. aaabbcccc will become a3b2c4 print list of words present in a text file containing all characters of given input string find the first non-repeating character of a given string check if two strings are rotations of each other. ABCD and CDAB are rotations. remove characters from first string which are present in second string print all duplicates (characters) in given string. remove all duplicates (characters) from the string Check whether two strings are anagrams of each other or not. Same characters and same number of Find if a set of given words can form a path. Path is possible if last character of a word is the first char count the occurences of a word in a text file replace all occurences of string2 in string1 with string3 remove all occurences of string2 from string1 find all the palindromes in given string. find the largest palindrome in a string. Palindrome is a string whose first and last characters are same Given a large string, you have to find out largest string such that all its character are consecutive. Given a dictionary and a string. Separate all words that can be in dictionary. Ex:- catsanddogs will giv print all substrings of given string Find out the minimum number of palindromes required to construct a string. Worst case is number of return shortest substring occuring only once in a given string. given an n*m matrix of characters. Find all the valid words present in it. how do you check if a given string is palindrome or not. Iterative and recursive algorithms. Which one
ng is also palindrome
Detect and remove loop in a linked list Delete Nodes which have a greater value on right side Reverse alternate k nodes in a linked list of size n (both recursive and iterative) merge sort for linked lists polynomial multiplication using linked lists split a circular linked list into two lists containing alternate nodes Delete a Node in doubly linked list Reverse a doubly linked list Remove duplicates from an unsorted linked list and also from sorted list Copy a linked list with next and random pointer Check if a string represented by a linked list is palindrome using recursion find out if Sum of any three numbers from three linked lists (one from each) is zero Union and intersection of two linked lists Implement stack using linked list such that push(), pop() and max() can be done in O(1) time Binary search in linked list (also rotated sorted list) Add numbers represented by linked lists (use recursion) convert doubly linked list to binary tree Flatten a linked list where one pointer points to next node and other to a linked list insert an element into already sorted linked list print reverse of linked list using recursion without modifying the list find the numbers whose sum is S in a given linked list of unsorted integers Segregate even numbers and odd numbers in a linked list All approaches for Finding the intersection point of two linked lists in the form of Y Memory efficient double linked list (represent double links by XOR of prev and next links ) Nth node from end Delete middle node from a linked list Convert a single linked list to double linked list. (recursive and iterative) matrix multiplication of two matrices represented by two linked lists sort a special linked list that is in ascending order and descending order alternately
Check if a binary tree is subtree of another binary tree Find the inorder successor in binary search tree Check if a given binary tree is foldable or not. i.e both left subtree and right subtree are mirror image Print all root-leaf paths of a given binary tree Construct tree from inorder and pre-order traversals Check if the tree is height balanced or not. Try it without computing height at every node. Level order traversal (zig-zag, bottom to top etc) Check if a given tree is binary search tree or not Convert a binary search tree to a sorted doubly linkedlist Least common ancestor of two nodes in binary search tree and then try for binary tree Find maximum depth or height of a tree with and without recursion Print inorder and preorder by single traversal make sibling pointers point to right siblings in O(N) Given binary tree find the largest subtree which is a BST in it. Level order traversal without using queue. Each node contains link to parent along with left and right evaluate an expression tree using stack Print all ancestors of a given node in a binary tree Find kth smallest element in binary search tree Find if there is a path from root to leaf whose sum is equal to S. Next do it for any path. Inorder traversal of a binary tree without using recursion and stack Convert a binary tree to binary search tree inplace without using extra space. convert zig-zag level order traversal of tree to doubly linked list Check if a given Binary Tree is SumTree.A SumTree is a Binary Tree where the value of a node is equa Print all the nodes that are in given range (K1 to k2) in a binary search tree. Print in ascending order. Sorted order printing of complete binary search tree represented as array Print nodes at k distance from root find the maximum width of a binary tree (maximum of widths of each level) Find distance between leftmost and rightmost leaf. They can be at different levels. find the diameter of a binary tree (maximum distance between two leaf nodes in the tree). Next find t Convert given tree to double tree. Double tree is formed by creating new node for each node and inse Convert a binary tree to its mirror tree Given root and a node find nodes which are k distance from the node either upward or downward. Find precedence order of alphabet set based on sorted words given as input Search for an element and return level if found How to serialize a binary search tree Iterative postorder traversal Reverse a binary tree Find if a tree is well ordered Find vertical sum of binary tree construct n*n matrix such that a[i,j] = 1 if I is ancestor of j in a binary search tree and vice-versa Find the minimum/maximum vertical sum (path from root to leaf) in a binary tree Find median in a Binary search tree Merge two binary search trees Find level order successor of binary tree where for every node we have pointer to parent node also. D Count internal nodes in a tree Balance an unbalanced binary tree Create a copy of the tree (clone)
How do you implement spell-checker. It should give suggestions for words as we type them like in ms
m like in ms-word.
Fake coin puzzle (number of weighings required to find the coin which is heavier than other coins of s Coin changing problem. (how many ways can we provide change for X Rupees with denominations of 8 queens problem Knight's tour problem . move the knight in a chess board such that all the boxes are toured atleast on find the second best player in Tournament Tree (Winners of knock out game become internal nodes o find the smallest angle between hands of a clock when time is given as input Pattern matching and regular expressions convert a binary representation of number to its 2's complement Rat in a Maze Problem.
nary tree)