162 Find Peak Element

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 index.

阅读更多

153 Find Minimum in Rotated Sorted Array

Suppose an array sorted in ascending order 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).

阅读更多

137 Single Number II

Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one.

Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

阅读更多

129 Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.

An example is the root-to-leaf path 1->2->3 which represents the number 123.

阅读更多

116 Populating Next Right Pointers in Each Node

Given a binary tree

1
2
3
4
5
struct TreeLinkNode {
TreeLinkNode *left;
TreeLinkNode *right;
TreeLinkNode *next;
}

阅读更多

114 Flatten Binary Tree to Linked List

Given a binary tree, flatten it to a linked list in-place.

For example,
Given

1
2
3
4
5
1
/ \
2 5
/ \ \
3 4 6

阅读更多

给Hexo博客添加Gitment评论系统

之前一直懒得给自己的博客搭建“多说”评论系统。但没想到的是,多说居然要在今年6月底停止服务了,着实令人诧异。偶然在知乎上看到一个基于github issue搭建的评论系统,名叫gitment。这位作者也是相当有想法,佩服佩服。技术类博客的受众终究还是广大同性交友网站代码分享网站的注册用户,利用gitment作为本网站的评论系统再好不过了。下面就简单介绍一下如何将Gitmemt嵌入到基于hexo的博客主题当中。

阅读更多

096 Unique Binary Search Trees

Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?

For example,
Given n = 3, there are a total of 5 unique BST’s.

阅读更多

090 Subsets II

Given a collection of integers that might contain duplicates, nums, return all possible subsets.

Note: The solution set must not contain duplicate subsets.

阅读更多

089 Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit.

Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.

阅读更多