自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(99)
  • 资源 (2)
  • 收藏
  • 关注

原创 Reverse Words in a String - LeetCode 151

题目描述:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C programmers: Try to solve it in-p

2015-05-28 20:49:35 438

原创 Rotate List - LeetCode 62

题目描述:Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.分析:给定一个单链表,要将每个节点往右旋转k个位置。举个

2015-05-27 22:43:24 300

原创 Construct Binary Tree from Inorder and Postorder Traversal - LeetCode 106

题目描述:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.Hide Tags Tree Array Depth-first Search分析:根据二叉树

2015-05-27 10:41:21 362

原创 Construct Binary Tree from Preorder and Inorder Traversal LeetCode 105

题目描述:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.Hide Tags Tree Array Depth-first Search分析:已知二叉

2015-05-27 10:22:00 393

原创 Maximum Product Subarray - LeetCode 152

题目描述:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the lar

2015-05-27 08:24:24 374

原创 Longest Consecutive Sequence - LeetCode 128

题目描述:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [

2015-05-27 08:22:01 368

原创 Kth Largest Element in an Array - LeetCode 215

题目描述: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.For example,Given [3,2,1,5,6,4] and k = 2, retur

2015-05-26 09:05:32 280

原创 House Robber II - LeetCode 213

题目描述:Note: This is an extension of House Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. Th

2015-05-26 08:42:26 336

原创 Contains Duplicate - LeetCode 217

题目描述:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every ele

2015-05-25 20:58:17 382

原创 Ubuntu下配置IPV6

ubuntu下配置ipv6步骤:1、安装miredo    打开终端,执行:sudo apt-get install miredo2、修改防火墙IPV6设置    终端执行    sudo gedit /etc/default/ufw    找到“ipv6=NO”,将其改成“IPV6=YES”3、修改hosts文件    下载ipv6-hosts,可以从http://c

2015-05-25 17:29:55 11336

原创 Remove Duplicates from Sorted Array II - LeetCode 80

题目描述:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the f

2015-05-24 22:47:15 352

原创 Reverse Linked List II - LeetCode 92

题目描述:Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisf

2015-05-24 22:14:05 257

原创 Minimum Size Subarray Sum - LeetCode 209

题目描述:Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, given the array [

2015-05-24 20:52:33 317

原创 String to Integer (atoi) - LeetCode 8

题目描述:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible inp

2015-05-24 17:18:10 353

原创 Pow(x, n) - LeetCode 50

题目描述:Implement pow(x, n).Hide Tags Math Binary Search分析:C++库中有pow(double x,int y),但是只针对指数为非负的。因此本题只需特殊考虑参数为负数的情况。方法一:1. 当指数为0时,幂为1;2. 当指数为正数时,结果为pow();3. 当指数为负数时,结果为pow()的倒数备注:在考虑第

2015-05-24 15:57:24 643

原创 Two Sum - LeetCode 1

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, where

2015-05-23 23:21:31 313

原创 Convert Sorted Array to Binary Search Tree - LeetCode 108

题目描述:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Hide Tags Tree Depth-first Search分析:要构造平衡的二叉搜索树(AVL),必须满足平衡条件:它是一棵空树或它的左右两个子树的高度差的绝对值不超过

2015-05-23 21:55:13 314

原创 Populating Next Right Pointers in Each Node II - LeetCode 117

题目描述:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use consta

2015-05-23 20:54:34 337

原创 Generate Parentheses - LeetCode 22

题目描述:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())"

2015-05-23 20:32:45 365

原创 Unique Binary Search Trees - LeetCode 96

题目描述:Given n, 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

2015-05-23 19:52:28 298

原创 Binary Tree Postorder Traversal - LeetCode 145

题目描述:Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},   1    \     2    /   3return [3,2,1].Note: Recursive sol

2015-05-22 23:01:58 345

原创 Swap Nodes in Pairs - LeetCode 24

题目描述:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant s

2015-05-22 21:16:41 287

原创 Populating Next Right Pointers in Each Node - LeetCode 116

题目描述:Given a binary tree    struct TreeLinkNode {      TreeLinkNode *left;      TreeLinkNode *right;      TreeLinkNode *next;    };Populate each next pointer to point to its next rig

2015-05-22 21:00:31 324

原创 Count Primes - LeetCode 204

题目描述:Description:Count the number of prime numbers less than a non-negative number, nclick to show more hints.References:How Many Primes Are There?(https://primes.utm.edu/howmany.html)Si

2015-05-20 21:42:17 407

原创 Happy Number - LeetCode 202

题目描述:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the

2015-05-20 20:32:48 354

原创 Isomorphic Strings - LeetCode 205

题目描述:Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with a

2015-05-19 22:59:03 366

原创 Binary Tree Inorder Traversal - LeetCode 94

题目描述:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},   1    \     2    /   3return [1,3,2].Note: Recursive solut

2015-05-17 22:33:55 262

原创 Remove Linked List Elements - LeeCode 203

题目描述:Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5Credits:Special

2015-05-17 11:48:25 312

原创 Reverse Linked List - LeetCode 206

题目描述:Reverse a singly linked list.click to show more hints.Hint:A linked list can be reversed either iteratively or recursively. Could you implement both?Hide Tags Linked List分析:反转一个单链

2015-05-17 10:22:27 300

原创 Find Peak Element - LeetCode 162

题目描述:A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks,

2015-05-16 21:22:42 373

原创 Spiral Matrix II - LeetCode 59

题目描述: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

2015-05-16 20:02:18 330

原创 Spiral Matrix - LeetCode 54

题目描述:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8

2015-05-16 17:39:20 275

原创 Set Matrix Zeroes - LeetCode 73

题目描述:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution us

2015-05-15 22:08:20 271

原创 Rotate Image - LeetCode 48

题目描述: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?Tags: Array分析:此题要求将一个 n x n 方阵顺时针旋转90度。分析后可发

2015-05-15 20:52:47 397

原创 Container With Most Water - LeetCode 11

题目描述: 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).

2015-05-13 22:45:17 360

原创 Minimum Path Sum - LeetCode 64

题目描述: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 r

2015-05-13 21:33:23 335

原创 Binary Tree Preorder Traversal - LeetCode 144

题目描述:Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},   1    \     2    /   3return [1,2,3].Note: Recursive soluti

2015-05-13 20:35:42 294

原创 Best Time to Buy and Sell Stock - LeetCode 121

题目描述:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the st

2015-05-13 10:11:46 300

原创 Sort Colors - LeetCode 75

题目描述: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 th

2015-05-13 08:36:36 331

原创 Unique Paths II - LeetCode 63

题目描述:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectivel

2015-05-07 21:04:05 300

程序员面试题精选-何海涛

这是一本很好的程序员面试书籍,短期内能有较大提高,适合面试前3个月开始看

2015-06-02

空空如也

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

TA关注的人

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