自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 [leetcode] 191. Number of 1 Bits

Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit integer ’11' has binary representation000000

2015-11-30 21:27:33 295

原创 [leetcode] 84. Largest Rectangle in Histogram

Givenn non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where widt

2015-11-30 15:29:02 393

原创 [leetcode] 96. Unique Binary Search Trees

Givenn, 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.1 3 3 2 1 \

2015-11-27 21:47:09 298

原创 [leetcode] 111. Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.这道题和二叉树相关,找出二叉树中从根节点到叶节点的最短路径长度,题目

2015-11-27 10:42:20 308

原创 [leetcode] 233. Number of Digit One

Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6, because digit 1 occurred in the follow

2015-11-26 20:42:31 485

原创 [leetcode] 289. Game of Life

According to theWikipedia's article: "TheGame of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given aboard

2015-11-26 11:30:03 480

原创 [leetcode] 268. Missing Number

Given an array containingn distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums = [0, 1, 3] return2.Note:Your algorith

2015-11-25 17:27:38 311

原创 [leetcode] 227. Basic Calculator II

Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division sh

2015-11-25 15:19:42 355

原创 [leetcode] 224. Basic Calculator

Implement a basic calculator to evaluate a simple expression string.The expression string may contain open( and closing parentheses), the plus+ or minus sign-,non-negative integers and

2015-11-24 18:48:05 404

原创 [leetcode] 201. Bitwise AND of Numbers Range

Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4.今天的题目是一道按位操作的题目,求一段数字区间中所有数字按位与的结果,题目难度为Medium。对于任意位,只要一个数中该位是0则结果中该位就是0,因为是按位与操作。我们再来看连续数据的特点,最大数和最小数

2015-11-24 11:11:24 306

原创 [leetcode] 52. N-Queens II

Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.这道题和第51题基本没有太大区别,题目难度为Hard。如果需要详细解释请看第51题(传送门),具体代码:class Solution

2015-11-24 10:14:34 366

原创 [leetcode] 282. Expression Add Operators

Given a string that contains only digits0-9 and a target value, return all possibilities to add binary operators (not unary) +,-, or * between the digits so they evaluate to the target val

2015-11-23 20:25:33 434

原创 [leetcode] 51. N-Queens

Then-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integern, return all distinct solutions to the n-queen

2015-11-23 11:09:46 493

原创 [leetcode] 188. Best Time to Buy and Sell Stock IV

Say you have an array for which theith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mostk transactions.Note:

2015-11-22 21:29:53 414

原创 [leetcode] 123. Best Time to Buy and Sell Stock III

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You

2015-11-22 20:27:44 420

原创 [leetcode] 149. Max Points on a Line

Givenn points on a 2D plane, find the maximum number of points that lie on the same straight line.今天的题目是给出平面坐标系上的n个点,找出一条直线最多穿过多少这些已知的点。题目难度为Hard。乍看起来可能无从下手,不过通过直线坐标公式y=kx+b可

2015-11-20 21:31:27 505

原创 [leetcode] 122. Best Time to Buy and Sell Stock II

Say you have an array for which theith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy o

2015-11-20 11:07:18 390

原创 [leetcode] 121. Best Time to Buy and Sell Stock

Say you have an array for which theith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the s

2015-11-19 16:22:14 579

原创 [leetcode] 287. Find the Duplicate Number

Given an arraynums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate num

2015-11-19 15:18:00 525

原创 [leetcode] 3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo

2015-11-18 20:20:46 381

原创 [leetcode] 77. Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]

2015-11-18 16:35:44 394

原创 [leetcode] 174. Dungeon Game

The demons had captured the princess (P) 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 p

2015-11-18 14:41:03 480

原创 [leetcode] 1. Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, w

2015-11-17 14:33:24 469

原创 [leetcode] 142. Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up:Can you solve it without using extra space?这道

2015-11-16 10:14:57 339

原创 [leetcode] 141. Linked List Cycle

Problem:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra spact?这道题让检测链表是否存在回环,难度为Medium。最直观的想法是使用HashTable,每遍历一个节点检测是否已经存在,如果不存在把它存入H

2015-11-16 09:27:23 351

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除