- 博客(27)
- 收藏
- 关注
原创 138. Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.Example 1:Input:{"$id":"1","next...
2019-11-20 03:43:04 179
原创 692. Top K Frequent Words
Given a non-empty list of words, return the k most frequent elements.Your answer should be sorted by frequency from highest to lowest. If two words have the same frequency, then the word with the low...
2019-11-20 02:27:08 182
原创 88. Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You may assume that n...
2019-11-20 01:54:10 163
原创 617. Merge Two Binary Trees
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary tree....
2019-11-11 16:29:38 140
原创 接口和抽象类
接口:定义一个规范,定义可以做什么事情。抽象类:是一个类,可以实现某个接口,实现其中一些方法,也可以不实现其中的方法,供子类去实现。举例:接口: 可开关的 - 有三个方法 close() open() lock()抽象类: 门子类: 木门 铁门 、。。抽象类门可以实现这个 可开关的接口,实现其中的 close() open() 方法,因为所有的门开关方式都一样,都是推或...
2019-11-11 15:42:41 234
原创 973. K Closest Points to Origin
We have a list of points on the plane. Find the K closest points to the origin (0, 0).(Here, the distance between two points on a plane is the Euclidean distance.)You may return the answer in any o...
2019-11-04 05:45:32 109
原创 819. Most Common Word
Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn’t banned, and that the answer...
2019-11-04 04:16:38 126
原创 179. Largest Number
Given a list of non negative integers, arrange them such that they form the largest number.Example 1:Input: [10,2]Output: "210"Example 2:Input: [3,30,34,5,9]Output: "9534330"Note: The result ...
2019-11-03 12:12:23 110
原创 103. Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tree...
2019-11-03 05:46:34 137
原创 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3 B...
2019-11-03 05:28:11 126
原创 222. Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes.Note:Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely fille...
2019-11-03 04:49:47 110
原创 1047. Remove All Adjacent Duplicates In String
Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them.We repeatedly make duplicate removals on S until we no longer can.Re...
2019-11-03 02:22:25 137
原创 160. Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin to intersect at node c1.Example 1:Input: intersect...
2019-11-02 15:34:20 133
原创 171. Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28 ...Example 1:Input: "A"...
2019-11-02 15:05:13 110
原创 314. Binary Tree Vertical Order Traversal
Given a binary tree, return the vertical order traversal of its nodes’ values. (ie, from top to bottom, column by column).If two nodes are in the same row and column, the order should be from left to...
2019-11-02 15:03:22 131
原创 215. Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input: [3,2,1,5,6,4] and k = 2Output: 5Exampl...
2019-11-02 13:58:36 122
原创 118. Pascal's Triangle
Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.In Pascal’s triangle, each number is the sum of the two numbers directly above it.class Solution { public L...
2019-11-02 10:54:24 135
原创 120. Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,7]...
2019-11-02 09:44:42 116
原创 174. Dungeon Game
The demons had captured the princess § and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially posit...
2019-11-02 09:25:10 167
原创 64. Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at an...
2019-11-02 08:54:13 166
原创 96. Unique Binary Search Trees
Given n, how many structurally unique BST’s (binary search trees) that store values 1 … n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total of 5 unique BST's: 1 3 ...
2019-11-02 02:10:17 111
原创 73. Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.Example 1:Input: [ [1,1,1], [1,0,1], [1,1,1]]Output: [ [1,0,1], [0,0,0], [1,0,1]]Follo...
2019-11-02 02:06:56 102
原创 264. Ugly Number II
Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.Example:Input: n = 10 Output: 12 Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12...
2019-11-01 07:04:12 149
原创 240. Search a 2D Matrix II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in each c...
2019-11-01 06:43:18 96
原创 1099. Two Sum Less Than K
Given an array A of integers and integer K, return the maximum S such that there exists i < j with A[i] + A[j] = S and S < K. If no i, j exist satisfying this equation, return -1.Example 1:In...
2019-11-01 02:53:03 236
原创 213. House Robber II
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is ...
2019-11-01 02:29:01 145
原创 198. House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house...
2019-11-01 02:00:40 105
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人