leetecode
文章平均质量分 59
奔跑的兔子V
这个作者很懒,什么都没留下…
展开
-
347. Top K Frequent Element(java)
Given a non-empty array of integers, return the k most frequent elements.For example,Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number原创 2016-06-10 14:32:43 · 721 阅读 · 0 评论 -
109. Convert Sorted List to Binary Search Tree
题目: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.解析:把有序的链表convert成AVL树想到使用递归,例如【1,2,3,4,5,6,7】中间的数4作为树的root,左子树为123,右子树为567。利原创 2016-06-03 16:03:25 · 300 阅读 · 0 评论 -
求0至大数之间的随机数
题目:给定一个String类型的大数,不能直接转化为Integer,类似如下要求The numbers can be arbitrarily large and are non-negative.Converting the input string to integer is NOT allowed.You should NOT use internal libr原创 2016-06-02 10:36:59 · 636 阅读 · 0 评论 -
66. Plus One(Java) & 43. Multiply Strings
题目:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.大意:一个非负正数用数组A表示,例原创 2016-05-29 16:23:44 · 471 阅读 · 0 评论 -
2. Add Two Numbers(Java)
题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a l原创 2016-05-29 20:54:10 · 322 阅读 · 0 评论 -
142. Linked List Cycle I&II
Linked List Cycle I 只是单纯地确定是否有cycle,可以使用两个指针(fast和slow),fast每次走两步,slow每次走一步。若最后有相交的节点,则有环;若fast节点为null,则无环。也可以使用其他方法,题目并没有要求不能破坏原链表。 相较于I,题目II要求不能修改原链表。题目:Given a linked list, return the node wh原创 2016-05-29 17:25:27 · 704 阅读 · 0 评论 -
154. Find Minimum in Rotated Sorted Array II
题目: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).Find the minimum element.The array may contain duplicates.此题原创 2016-05-27 15:32:54 · 199 阅读 · 0 评论 -
59. Spiral Matrix II
题目:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7原创 2016-05-27 13:12:48 · 209 阅读 · 0 评论 -
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原创 2016-05-27 13:06:24 · 218 阅读 · 0 评论 -
75. Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the intege原创 2016-05-27 13:03:21 · 242 阅读 · 0 评论 -
48. Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place?1.首先找旋转后的第一条规律,设n=4 [0][0]->[0][3]原创 2016-05-27 13:00:57 · 230 阅读 · 0 评论 -
11. Container With Most Water
Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two li原创 2016-05-27 12:58:54 · 239 阅读 · 0 评论 -
289. Game of Life
According to the Wikipedia’s article: “The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.”Given a board with m by原创 2016-05-27 12:54:35 · 322 阅读 · 0 评论 -
349. Intersection of Two Arrays I &&II (Java)
Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element in the result must be unique. The result原创 2016-05-27 12:56:58 · 3353 阅读 · 0 评论