摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 > 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example Given "25525511135", return [ "255. 阅读全文
摘要:
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 阅读全文