随笔分类 -  GeeksForGeeks

摘要:Given a sorted array of n distinct integers where each integer is in the range from 0 to m - 1 and m > n. Find the smallest number that is missing fro 阅读全文
posted @ 2017-12-05 12:52 Review->Improve 阅读(194) 评论(0) 推荐(0)
摘要:Given a Binary Tree, write a function to check whether the given Binary Tree is a prefect Binary Tree or not. A Binary tree is Perfect Binary Tree in 阅读全文
posted @ 2017-10-10 05:16 Review->Improve 阅读(298) 评论(0) 推荐(0)
摘要:Given a binary tree, you need to check whether sum of all covered elements is equal to sum of all uncovered elements or not. In a binary tree, a node 阅读全文
posted @ 2017-10-10 04:45 Review->Improve 阅读(407) 评论(0) 推荐(0)
摘要:Given an unsorted array of nonnegative integers, find a continous subarray which adds to a given number. Examples: There may be more than one subarray 阅读全文
posted @ 2017-10-03 04:02 Review->Improve 阅读(493) 评论(0) 推荐(0)
摘要:Given a binary tree, generate all root to leaf paths of a binary tree. Example: Example Tree The output for the above example is [[1, 2, 4], [1, 2, 5] 阅读全文
posted @ 2017-10-03 00:34 Review->Improve 阅读(184) 评论(0) 推荐(0)
摘要:Given A binary Tree, how do you remove all the half nodes (which has only one child)? Note leaves should not be touched as they have both children as 阅读全文
posted @ 2017-09-29 01:47 Review->Improve 阅读(196) 评论(0) 推荐(0)
摘要:Given n friends, each one can remain single or can be paired up with some other friend. Each friend can be paired only once. Find out the total number 阅读全文
posted @ 2017-09-28 04:58 Review->Improve 阅读(732) 评论(0) 推荐(0)
摘要:The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two leaves in the tree. The diagram below shows 阅读全文
posted @ 2017-09-15 03:58 Review->Improve 阅读(251) 评论(0) 推荐(0)
摘要:Given a binary tree with each node having one extra field of nextRight. nextRight points to the next right node of the same level. Initially all nodes 阅读全文
posted @ 2017-09-13 14:01 Review->Improve 阅读(241) 评论(0) 推荐(0)
摘要:Given a Binary Tree, find if there exist edge whose removal creates two trees of equal size. Examples: To find whether such an edge exists, we need to 阅读全文
posted @ 2017-09-13 06:53 Review->Improve 阅读(391) 评论(0) 推荐(0)
摘要:Given a binary tree, check whether it is a mirror of itself using both recursion and iterative approach. Examples: Solution 1. Recursion For two trees 阅读全文
posted @ 2017-09-07 00:33 Review->Improve 阅读(175) 评论(0) 推荐(0)
摘要:Given a Binary Tree, extract all leaves of it in a Doubly Linked List (DLL). Note that the DLL need to be created in-place. Assume that the node struc 阅读全文
posted @ 2017-09-06 12:54 Review->Improve 阅读(281) 评论(0) 推荐(0)
摘要:Consider a game where a player can score 3 or 5 or 10 points in a move. Given a total score n, find the number of ways to reach the given score. Examp 阅读全文
posted @ 2017-09-06 11:57 Review->Improve 阅读(921) 评论(0) 推荐(0)
摘要:You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. A pair (c, d) can follow another pair (a, 阅读全文
posted @ 2017-09-05 09:13 Review->Improve 阅读(539) 评论(0) 推荐(0)
摘要:Given a binary search tree with the following tree node definition. next points to a node's inorder successor. Populate inorder successor for all node 阅读全文
posted @ 2017-08-23 03:42 Review->Improve 阅读(346) 评论(0) 推荐(0)
摘要:Given a binary tree, get all nodes that don't have sibling node, excluding the root node. Level order and pre order solutions. 阅读全文
posted @ 2017-08-23 00:39 Review->Improve 阅读(278) 评论(0) 推荐(0)
摘要:Find Maximum Number that can be formed using all digits in the given integer. Solution 1. O(n * log n) runtime, O(n) space using sorting A simple solu 阅读全文
posted @ 2017-08-22 05:16 Review->Improve 阅读(381) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, sort this array using tree sort. 1. Create a binary search tree by inserting array elements. 2. Perform in order 阅读全文
posted @ 2017-08-22 01:44 Review->Improve 阅读(232) 评论(0) 推荐(0)
摘要:Given Inorder and Preorder traversals of a binary tree, print Postorder traversal. Example: A naive solution is to first construct the given tree, the 阅读全文
posted @ 2017-08-22 00:59 Review->Improve 阅读(340) 评论(0) 推荐(0)
摘要:Give a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from root node down to the nearest leaf n 阅读全文
posted @ 2017-08-19 04:05 Review->Improve 阅读(153) 评论(0) 推荐(0)