Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < versio…
Leetcode 91. Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’…
Leetcode 97. Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given: s1 = “…
Leetcode 124. Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes f…
Leetcode 174. Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dunge…
Leetcode 95. Unique Binary Search Trees II
Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1R…
Leetcode 159. Longest Substring with At Most Two Distinct Characters
Given a string, find the length of the longest substring T that contains at most 2 distinct characters. For ex…
Leetcode 226. Invert Binary Tree
Invert a binary tree. 4 / 2 7 / \ / 1 3 6 9 to 4 / 7 2 / \ / 9 6 3 1 思路: 递归的翻转每个节点的左右子树,然后交换每个节点的左右子树。 public …
Leetcode 132. Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum c…
Leetcode 71. Simplify Path
Given an absolute path for a file (Unix-style), simplify it. For example, path = “/home/”, => &…
Leetcode 135. Candy
There are N children standing in a line. Each child is assigned a rating value. You are giving candies to thes…
Leetcode 329. Longest Increasing Path in a Matrix
Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move t…