随笔分类 -  LeetCode

上一页 1 ··· 44 45 46 47 48 49 50 51 52 ··· 61 下一页
摘要:Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... Example: Input: nums = [3,5,2,1,6,4] Output: 阅读全文
posted @ 2016-02-02 13:22 Grandyang 阅读(21794) 评论(0) 推荐(0) 编辑
摘要: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, 阅读全文
posted @ 2016-02-01 10:52 Grandyang 阅读(11363) 评论(5) 推荐(0) 编辑
摘要:Given a file and assume that you can only read the file using a given method read4, implement a method to read n characters. Method read4: The API rea 阅读全文
posted @ 2016-02-01 02:54 Grandyang 阅读(18019) 评论(2) 推荐(0) 编辑
摘要:Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it up 阅读全文
posted @ 2016-01-31 08:59 Grandyang 阅读(15575) 评论(3) 推荐(1) 编辑
摘要:Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected 阅读全文
posted @ 2016-01-28 15:14 Grandyang 阅读(17117) 评论(2) 推荐(0) 编辑
摘要:Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be for 阅读全文
posted @ 2016-01-28 12:42 Grandyang 阅读(10921) 评论(11) 推荐(1) 编辑
摘要:Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined as the sum of the eleme 阅读全文
posted @ 2016-01-27 11:33 Grandyang 阅读(18180) 评论(6) 推荐(0) 编辑
摘要:Given an m x n integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: le 阅读全文
posted @ 2016-01-21 13:54 Grandyang 阅读(19760) 评论(8) 推荐(1) 编辑
摘要:Write a program to find the nthsuper ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime listprimesof s... 阅读全文
posted @ 2016-01-20 13:45 Grandyang 阅读(15349) 评论(2) 推荐(0) 编辑
摘要:Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Example 1: Example 2: Note:You may assume all input has v 阅读全文
posted @ 2016-01-18 13:59 Grandyang 阅读(34447) 评论(12) 推荐(2) 编辑
摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the... 阅读全文
posted @ 2016-01-18 13:20 Grandyang 阅读(14493) 评论(0) 推荐(1) 编辑
摘要:Given an integer, write a function to determine if it is a power of three. Example 1: Example 2: Example 3: Example 4: Follow up:Could you do it witho 阅读全文
posted @ 2016-01-18 06:41 Grandyang 阅读(19691) 评论(10) 推荐(0) 编辑
摘要:You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return  阅读全文
posted @ 2016-01-18 02:39 Grandyang 阅读(41414) 评论(17) 推荐(3) 编辑
摘要:Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. Th 阅读全文
posted @ 2016-01-17 07:07 Grandyang 阅读(17822) 评论(6) 推荐(0) 编辑
摘要:There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every t 阅读全文
posted @ 2016-01-04 20:06 Grandyang 阅读(14529) 评论(7) 推荐(0) 编辑
摘要:Given a string arraywords, find the maximum value oflength(word[i]) * length(word[j])where the two words do not share common letters. You may assume t... 阅读全文
posted @ 2015-12-30 21:06 Grandyang 阅读(11285) 评论(4) 推荐(0) 编辑
摘要:Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your 阅读全文
posted @ 2015-12-29 13:09 Grandyang 阅读(19842) 评论(1) 推荐(0) 编辑
摘要:You are given an integer array nums and you have to return a new counts array. The countsarray has the property where counts[i] is the number of small 阅读全文
posted @ 2015-12-26 17:42 Grandyang 阅读(30860) 评论(18) 推荐(0) 编辑
摘要:Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloon 阅读全文
posted @ 2015-11-30 10:21 Grandyang 阅读(28787) 评论(23) 推荐(5) 编辑
摘要:For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible roote 阅读全文
posted @ 2015-11-27 12:25 Grandyang 阅读(26019) 评论(10) 推荐(0) 编辑

上一页 1 ··· 44 45 46 47 48 49 50 51 52 ··· 61 下一页
Fork me on GitHub