- 博客(7)
- 收藏
- 关注
原创 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 now is to design a rectangular web page, whose length L
2017-01-25 16:30:47 443
原创 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: 3Explanation: The first two digits or the last three digits are consecutiv
2017-01-20 16:17:07 468
原创 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 the number of contiguous occurrences of characters '1' and '2' generates
2017-01-20 16:11:56 752
原创 LeetCode题解:Reverse String
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".思路:当然可以用双指针来做,不过最简单的还使用STL。题解:std::string reverseString(st
2017-01-17 16:37:56 441
原创 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, calculate the Hamming distance.思路:先通过异或得到
2017-01-17 16:33:44 462
原创 LeetCode题解:Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",
2017-01-17 13:17:26 375
原创 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 greed factor gi, which is the minimum size of a c
2017-01-02 14:25:31 548 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人