Monthly Archives: February 2013
Convert a BST to a sorted circular doubly linked list
Question:Convert a BST to a sorted circular doubly linked list in-place. Solution: Courtesy : The Great Tree-List Recursion Problem
Matching Nuts And Bolts
Question: You are given a collection of nuts of different size and corresponding bolts. You can choose any nut & any bolt together, from which you can determine whether the nut is larger than bolt, smaller than bolt or matches … Continue reading
coins change
Question: Given 5 paise, 10 paise and 25 paise coins..list down all the possible set of coins change for 1 Rupee 5P coins 10P coins 25P coins ——————————– 20 0 0 18 1 0 16 2 0 15 0 1 … Continue reading
Binary Search Tree Check
Question: Given a binary tree, check whether it is a binary search tree or not. Solution 1: Solution 2: Efficient one
All Permutations of String
Question: Generate all permutations of a given string. Solution:
Reverse order of words in a sentence
Question: Given an input string, reverse all the words. To clarify, input: “Interviews are awesome!” output: “awesome! are Interviews”. Consider all consecutive non-whitespace characters as individual words. If there are multiple spaces between words reduce them to a single white … Continue reading
Check balanced parentheses
Question: Given a string which contains alpha numeric characters with opening and closing parentheses, check whether parenthesis are balanced correctly. Solution:
First non repeated character in string
Question: Find the first non-repeated (unique) character in a given string. Solution: Let’s use the hashtable to store the number occurrences of each character in the given string scanning from left to right. Then perform a second pass and check … Continue reading
Anagram Strings
Question: Given two strings, check if they’re anagrams or not. Two strings are anagrams if they are written using the same exact letters, ignoring space, punctuation and capitalization. Each letter should have the same count in both strings. For example, … Continue reading