自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Magi Su的技术回收站

在虚构的故事当中寻求真实感的人脑袋一定有问题

  • 博客(24)
  • 收藏
  • 关注

原创 LeetCode题解:Letter Combinations of a Phone Number

Letter Combinations of a Phone NumberGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone butto

2013-10-31 03:40:46 965

原创 LeetCode题解:Pascal's triangle I and II

Pascal's TriangleGiven numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]Pas

2013-10-31 03:22:22 1395

原创 LeetCode题解:Reverse integer

Reverse IntegerReverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321思路:不断用对10取余的方法分离数字,然后反过来即可。注意符号位。题解:class Solution {public: int reverse(i

2013-10-27 13:54:12 721

原创 LeetCode题解:Single Number I and II

Single NumberGiven an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it

2013-10-27 13:47:34 3813 3

原创 LeetCode题解:Maximum Depth of Binary Tree

Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.思路:树

2013-10-27 13:40:21 1929

原创 LeetCode题解:Copy List with Random Pointer

Copy List with Random PointerA 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.思

2013-10-27 13:34:13 1225

原创 LeetCode题解:Valid Palindrome

Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."rac

2013-10-27 08:37:40 778

原创 LeetCode题解:Restore IP Addresses

Restore IP AddressesGiven a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.2

2013-10-27 04:24:59 810

原创 LeetCode题解:Unique Paths II

Unique Paths IIFollow 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 respe

2013-10-26 19:38:27 842

原创 LeetCode题解:Unique Paths

Unique PathsA robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is tryi

2013-10-26 19:04:02 781

原创 LeetCode题解:Valid Sudoku

Valid SudokuDetermine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character'.'.A

2013-10-26 15:43:34 2869

原创 LeetCode题解:Anagrams

AnagramsGiven an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.思路:关键在于对题目的理解。本文中anagrams指只有字母排列顺序不同的单词,例如eat,ate,tea。倘若有多组anagrams,那

2013-10-26 15:11:12 4023

原创 LeetCode题解:Count and Say

Count and SayThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is r

2013-10-26 13:58:04 958

原创 LeetCode题解:Subsets I and II

SubsetsGiven a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subset

2013-10-24 04:28:32 1469

原创 LeetCode题解:Merge Sorted Array

Merge Sorted ArrayGiven two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of el

2013-10-24 04:04:54 1385

翻译 C++语言的表达式模板:表达式模板的入门性介绍

时至今日,模板的使用已经远远超过C++模板的发明者所预期的范畴。模板的使用已经涵盖 了泛型编程,编译时求值,表达式模板库,模板元编程,产生式编程(generative programming)等诸多领域。在这篇文章中,我们仅限于探讨一些表达式模板的编程知识, 侧重于编写表达式模板程序库这个方面。

2013-10-23 07:16:32 11849 5

原创 LeetCode题解:Pow(x,n)

Pow(x, n)Implement pow(x, n).思路:1. 直接循环求解,最简单的方法2. 分而治之,可以减少一半的乘法。3. 如果n可能是浮点数的话,要考虑用对数运算。题解:class Solution {public: double pow_proc(double x, int n) { double p;

2013-10-22 11:37:06 996

原创 LeetCode题解:Valid Parentheses

Valid ParenthesesGiven a string containing just the characters '(', ')','{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()

2013-10-22 11:14:44 708

原创 LeetCode题解:Sum Root to Leaf Numbers

Sum Root to Leaf NumbersGiven a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the numb

2013-10-22 11:04:35 747

原创 LeetCode题解:Jump Game

Jump GameGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.

2013-10-21 00:45:50 750

原创 LeetCode题解:Balanced Binary Tree

Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of

2013-10-20 07:21:04 697

原创 LeetCode题解:Merge k Sorted Lists

Merge k Sorted ListsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity思路:标准的merge sort使用min(x,y),这里需要的是min(x1, x2, ... xk),可以用堆实现。题解:/** * D

2013-10-18 19:55:20 788

原创 LeetCode题解:Length of Last Word

Length of Last WordGiven a string s consists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word does not exist, return

2013-10-17 09:11:08 937

原创 LeetCode题解:Two Sum

Two SumGiven 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 ta

2013-10-16 05:33:59 8191 1

空空如也

空空如也

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

TA关注的人

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