自定义博客皮肤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的技术回收站

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

原创 LeetCode题解:Island Perimeter

You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally...

2017-02-05 10:03:23

阅读数 327

评论数 0

原创 LeetCode题解:Arithmetic Slices

A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the...

2017-02-04 19:21:14

阅读数 378

评论数 0

原创 LeetCode题解:FizzBuzz

Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the n...

2017-02-04 18:13:22

阅读数 367

评论数 0

原创 LeetCode题解:Counting Bits

Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation...

2017-02-04 18:06:58

阅读数 265

评论数 0

原创 LeetCode题解:Battleships in a Board

Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with ...

2017-02-04 17:47:19

阅读数 275

评论数 0

原创 LeetCode题解: Number Complement

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The g...

2017-02-04 17:21:06

阅读数 390

评论数 0

原创 LeetCode题解:Teemo Attacking

In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ...

2017-02-04 15:59:23

阅读数 264

评论数 0

原创 LeetCode题解:Construct the Rectangle

For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by...

2017-01-25 16:30:47

阅读数 252

评论数 0

原创 LeetCode题解:Max Consecutive Ones

Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first...

2017-01-20 16:17:07

阅读数 288

评论数 0

原创 LeetCode题解:Magical String

A magical string S consists of only '1' and '2' and obeys the following rules: The string S is magical because concatenating t...

2017-01-20 16:11:56

阅读数 565

评论数 0

原创 LeetCode题解:Reverse String

Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". ...

2017-01-17 16:37:56

阅读数 263

评论数 0

原创 LeetCode题解:Hamming Distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, ...

2017-01-17 16:33:44

阅读数 318

评论数 0

原创 LeetCode题解:Longest Valid Parentheses

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses subst...

2017-01-17 13:17:26

阅读数 202

评论数 0

原创 LeetCode题解:Assign Cookies

Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a ...

2017-01-02 14:25:31

阅读数 306

评论数 1

原创 LeetCode题解:Compare two version numbers version1 and version2.

Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0.You m...

2015-05-16 13:48:36

阅读数 852

评论数 0

原创 Levenshtein Edit distance

似乎在LeetCode里面也有,不过这里是为了解决另外的问题而做的。假设

2014-10-13 06:36:37

阅读数 649

评论数 0

原创 PageRank的模拟计算

源于Stanford在Coursera上的Mining Massive Datasets课程。Week 1里的作业

2014-10-05 13:36:24

阅读数 768

评论数 0

原创 LeetCode题解:Word Search

Word Search Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent...

2014-01-13 05:54:54

阅读数 885

评论数 0

原创 LeetCode题解:Distinct Subsequences

Distinct Subsequences Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new stri...

2014-01-08 13:07:15

阅读数 689

评论数 0

原创 LeetCode题解:Candy

Candy There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to th...

2014-01-07 14:26:16

阅读数 1136

评论数 1

原创 LeetCode题解: Valid Number

Valid Number Validate if a given string is numeric. Some examples: "0" => true " 0.1 " => true "abc" =>...

2013-12-16 13:12:06

阅读数 1725

评论数 0

原创 LeetCode题解:Implement strStr()

Implement strStr() Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack...

2013-12-16 06:37:53

阅读数 1899

评论数 0

原创 Amazon DynamoDB的模型

Amazon的DynamoDB是一个NoSQL类型的数据库。 数据库(Database)是由表(Table)组成的。每个表则由项(Item)组成。每一项包含任意个属性(Attribute),但是总共大小不能超过64KB。每个属性都是一个名字/值组成的对(name/value pair)。...

2013-12-11 14:07:36

阅读数 924

评论数 0

原创 LeetCode题解:LRU Cache

LRU Cache Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. ge...

2013-12-02 16:24:01

阅读数 1736

评论数 2

原创 LeetCode题解:Wildcard Matching

Wildcard Matching Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. ...

2013-11-30 03:35:09

阅读数 1050

评论数 0

原创 LeetCode题解:Sqrt(x)

Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x. 思路: 可以考虑二分搜索,但是二分搜索的起点不好判定,不过可以预先计算好numeric_limits::max()的平方根,然后搜索...

2013-11-29 05:10:12

阅读数 1404

评论数 0

原创 LeetCode题解:Divide Two Integers

Divide Two Integers Divide two integers without using multiplication, division and mod operator. 思路: 核心思想是:令试除数等于除数,如果试除数小于被除数,那么试除数乘二,商乘二,继续比...

2013-11-29 04:42:14

阅读数 786

评论数 0

原创 LeetCode题解:Evaluate Reverse Polish Notation

Evaluate Reverse Polish Notation Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Eac...

2013-11-28 03:43:50

阅读数 3281

评论数 1

原创 LeetCode题解:Search in Rotated Sorted Array

Search in Rotated Sorted Array 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...

2013-11-26 07:02:34

阅读数 1451

评论数 0

原创 LeetCode题解: Search for a Range

Search for a Range Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime...

2013-11-26 06:10:53

阅读数 755

评论数 0

原创 LeetCode题解:Surrounded Regions

Surrounded Regions Total Accepted: 1947 Total Submissions: 13017 Given a 2D board containing 'X' and 'O', capture all region...

2013-11-26 04:18:02

阅读数 1141

评论数 0

原创 LeetCode题解: Reverse Linked List II

Reverse Linked List II Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->...

2013-11-26 03:41:01

阅读数 3496

评论数 3

原创 LeetCode题解: Construct Binary Tree from Preorder and Inorder Traversal

Construct Binary Tree from Preorder and Inorder Traversal Given preorder and inorder traversal of a tree, construct the binary tree. Note: You...

2013-11-25 15:07:45

阅读数 782

评论数 0

原创 LeetCode题解: Construct Binary Tree from Inorder and Postorder Traversal

Construct Binary Tree from Inorder and Postorder Traversal Given inorder and postorder traversal of a tree, construct the binary tree. Note: You...

2013-11-25 14:47:42

阅读数 1102

评论数 0

原创 LeetCode题解:Decode Ways

Decode Ways A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -&...

2013-11-25 13:52:04

阅读数 2237

评论数 0

原创 LeetCode题解:Combinations

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 solut...

2013-11-25 03:58:10

阅读数 707

评论数 0

原创 LeetCode题解:3sum closest

3Sum Closest Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of ...

2013-11-25 00:48:54

阅读数 1126

评论数 1

原创 LeetCode题解:Combination Sum I and II

Combination Sum Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums ...

2013-11-25 00:29:12

阅读数 1057

评论数 1

原创 LeetCode题解:3Sum

3Sum Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives t...

2013-11-24 15:22:50

阅读数 1114

评论数 1

原创 LeetCode题解:Merge/Insert Interval

Merge Intervals Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10...

2013-11-24 06:36:59

阅读数 1008

评论数 1

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