摘要: For an array, we can build a SegmentTree for it, each node stores an extra attributecount to denote the number of elements in the the array which valu 阅读全文
posted @ 2016-04-05 17:58 哥布林工程师 阅读(187) 评论(0) 推荐(0) 编辑
摘要: For an integer array (index from 0 to n-1, where n is the size of this array), in the corresponding SegmentTree, each node stores an extra attribute m 阅读全文
posted @ 2016-04-05 17:55 哥布林工程师 阅读(152) 评论(0) 推荐(0) 编辑
摘要: For a Maximum Segment Tree, which each node has an extra value max to store the maximum value in this node's interval. Implement a modify function wit 阅读全文
posted @ 2016-04-05 17:54 哥布林工程师 阅读(147) 评论(0) 推荐(0) 编辑
摘要: The structure of Segment Tree is a binary tree which each node has two attributesstart and end denote an segment / interval. start and end are both in 阅读全文
posted @ 2016-04-05 17:52 哥布林工程师 阅读(114) 评论(0) 推荐(0) 编辑
摘要: The structure of Segment Tree is a binary tree which each node has two attributesstart and end denote an segment / interval. start and end are both in 阅读全文
posted @ 2016-04-05 17:51 哥布林工程师 阅读(98) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a functio 阅读全文
posted @ 2016-04-05 17:50 哥布林工程师 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target va 阅读全文
posted @ 2016-04-05 17:41 哥布林工程师 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array of n integers, find the starting and ending position of a given target value. If the target is not found in the array, return [-1 阅读全文
posted @ 2016-04-05 17:11 哥布林工程师 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Write an efficient algorithm that searches for a value in an m x n matrix, return the occurrence of it. This matrix has the following properties: Inte 阅读全文
posted @ 2016-04-05 16:51 哥布林工程师 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all the keys of tree in range k1 to k2. i.e. print all x s 阅读全文
posted @ 2016-04-05 12:48 哥布林工程师 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Given a directed graph, design an algorithm to find out whether there is a route between two nodes. Example Given graph: A >B >C \ | \ | \ | \ v ->D > 阅读全文
posted @ 2016-04-05 12:40 哥布林工程师 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Given a list, rotate the list to the right by k places, where k is non-negative. Example Given 1->2->3->4->5 and k = 2, return 4->5->1->2->3. /** * De 阅读全文
posted @ 2016-04-05 12:24 哥布林工程师 阅读(103) 评论(0) 推荐(0) 编辑
摘要: You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise). Example Given a matrix [ [1,2], [3,4] ] rotate it b 阅读全文
posted @ 2016-04-05 11:52 哥布林工程师 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given a roman numeral, convert it to an integer. The answer is guaranteed to be within the range from 1 to 3999. Example IV -> 4 XII -> 12 XXI -> 21 X 阅读全文
posted @ 2016-04-05 11:12 哥布林工程师 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from position m to n. Notice Given m, n satisfy the following condition: 1 ≤ m ≤ n ≤ length of list. Given m, n satisfy the foll 阅读全文
posted @ 2016-04-05 05:51 哥布林工程师 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example Given "25525511135", return [ "255. 阅读全文
posted @ 2016-04-05 04:25 哥布林工程师 阅读(188) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list L: L0 → L1 → … → Ln-1 → Ln reorder it to: L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → … Example Given 1->2->3->4->null, reorder it to 阅读全文
posted @ 2016-04-05 02:56 哥布林工程师 阅读(125) 评论(0) 推荐(0) 编辑