摘要:
One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, 阅读全文
摘要:
Design a data structure that supports all following operations in average O(1) time. Example: 阅读全文
摘要:
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov 阅读全文
摘要:
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree [ 阅读全文
摘要:
题目1: Given a binary tree Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to 阅读全文
摘要:
本文还是总结自Jikai Tang的视频和个人主页 1. 相遇性问题 Leetcode 167. Two Sum II Leetcode 15. 3Sum. 注意如何避免取到重复的解。 阅读全文
摘要:
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its inde 阅读全文
摘要:
根据Jikai Tang的网站和视频总结如下, http://www.tangjikai.com/algorithms/leetcode-binary-search 1. 在sorted array里面找一个特定的数。 由于left和right可以相等,所以L2使用的是while l <= r。L3 阅读全文
摘要:
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
摘要:
complete binary tree (CBT) 的定义和 Full binary tree (FBT)类似。如果上图中这个深度为3的binary tree有15个node (2**depth - 1), 那么这个深度为3的binary tree就被填满了,是FBT。 上图中是一个CBT,因为他 阅读全文