自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

LandscapeMi

landscapemi的博客

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

原创 leetcode:Bit Manipulation: Reverse Bits(190)

Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110

2016-08-31 15:26:57 195

原创 leetcode:Bit Manipulation:Single Number II(137)

Given an array of integers, every element appears three times except for one. Find that single one.class Solution { public: int singleNumber(vector<int>& nums) { int length = nums.siz

2016-08-31 15:25:41 198

原创 leetcode:bfs: Remove Invalid Parentheses(301)

Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may contain letters other than the parentheses ( and ).Examp

2016-08-31 15:22:07 212

原创 leetcode: Number of Islands(200)

https://leetcode.com/problems/number-of-islands/class Solution {public: bool dfs(int i,int j,vector<vector<char>> &grid) { if(i>=0&&i<grid.size()&&j>=0&&j<grid[i].size()&&grid[i][j]=='1

2016-08-31 15:19:11 195

原创 leetcode:Union Find:Surrounded Regions(130)

class Solution { public: void process(int i,int j,vector<vector<char> >& board) { int m=board.size(); int n=board[0].size(); typedef pair<int,int> point;

2016-08-31 15:16:21 251

原创 leetcode:Trie:Word Search II(212)

https://leetcode.com/problems/word-search-ii/struct TrieNode{ bool isEnd; TrieNode *children[26]; TrieNode() : isEnd(false) { for (int i = 0; i < 26; i++) {

2016-08-31 15:05:09 301

原创 leetcode:Trie:Add and Search Word - Data structure design(211)

https://leetcode.com/problems/add-and-search-word-data-structure-design/class TrieNode { public: bool isEnd; TrieNode *children[26]; TrieNode() : isEnd(false) { fo

2016-08-31 15:03:01 213

原创 leetcode:Trie:Implement Trie (Prefix Tree)(208)

Implement a trie with insert, search, and startsWith methods.class TrieNode { public: char var; bool isWord; TrieNode* children[26]; // Initialize your data structure here.

2016-08-31 15:01:46 176

原创 leetcode: Segment Tree:Range Sum Query - Mutable(307)

https://leetcode.com/problems/range-sum-query-mutable/class NumArray {public: NumArray(vector<int> &nums) { num.resize(nums.size() + 1); bit.resize(nums.size() + 1); for (i

2016-08-31 14:58:12 234

原创 leetcode:Data Stream as Disjoint Intervals(352)

https://leetcode.com/problems/data-stream-as-disjoint-intervals/class SummaryRanges { public: /** Initialize your data structure here. */ void addNum(int val) { auto it = st.low

2016-08-31 14:56:04 239

原创 leetcode:Binary Search Tree:Contains Duplicate III(220)

Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i and j is

2016-08-31 14:54:34 191

原创 leetcode:Brainteaser: Nim Game(292)

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the

2016-08-31 14:50:39 185

原创 leetcode: Memoization:Longest Increasing Path in a Matrix(329)

https://leetcode.com/problems/longest-increasing-path-in-a-matrix/class Solution {public: bool checkRange(vector<vector<int> >& matrix, int x, int y) { int n = matrix.size(), m = matrix[0]

2016-08-31 14:48:48 170

原创 leetcode: Reservoir Sampling:Linked List Random Node(382)

Given a singly linked list, return a random node’s value from the linked list. Each node must have the same probability of being chosen.Follow up: What if the linked list is extremely large and its le

2016-08-31 14:45:38 221

原创 leetcode:数学:spuer pow(372)

https://leetcode.com/problems/super-pow/http://blog.csdn.net/happyxuma1991/article/details/51867822class Solution { const int base = 1337; int powmod(int a, int k) //a^k mod 1337 where 0 <=

2016-08-31 14:24:20 259

原创 leetcode:数学: Largest Divisible Subset(368)

https://leetcode.com/problems/largest-divisible-subset/http://blog.csdn.net/qq508618087/article/details/51767785class Solution { public: vector<int> largestDivisibleSubset(vector<int>& nums) {

2016-08-31 14:21:32 198

原创 leetcode:数学:Water and Jug Problem(365)

https://leetcode.com/problems/water-and-jug-problem/http://www.cnblogs.com/grandyang/p/5628836.htmlclass Solution {public: bool canMeasureWater(int x, int y, int z) { return z == 0 || (x +

2016-08-31 14:20:14 257

原创 leetcode:数学:Count Numbers with Unique Digits(357)

Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Example: Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < 100, excludi

2016-08-31 14:19:06 251

原创 leetcode:数学:Integer Break(343)

Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, return 1

2016-08-31 14:17:39 251

原创 leetcode:数学:Self Crossing(335)

https://leetcode.com/problems/self-crossing/http://www.cnblogs.com/grandyang/p/5216856.htmlclass Solution {public: bool isSelfCrossing(vector<int>& x) { for (int i = 3; i < x.size(); ++i)

2016-08-31 14:14:25 245

原创 leetcode:数学:Bulb Switcher(319)

There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turning off i

2016-08-30 15:58:51 226

原创 leetcode:数学:Bulb Switcher(319)

https://leetcode.com/problems/bulb-switcher/class Solution {public: int bulbSwitch(int n) { return (int)sqrt(n); }};

2016-08-30 15:57:56 191

原创 leetcode:数学: Super Ugly Number(313)

Write a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4, 7, 8, 13, 14, 16,

2016-08-30 15:55:04 324

原创 leetcode:数学: Perfect Squares(279)

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return

2016-08-30 15:53:29 258

原创 leetcode:数学: Ugly Number II(264)

Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly

2016-08-30 15:51:46 185

原创 leetcode:数学:Ugly Number(263)

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it in

2016-08-30 15:49:27 174

原创 leetcode:数学:Add Digits(258)

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, r

2016-08-30 15:47:43 280

原创 leetcode:数学:Number of Digit One(233)

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 following num

2016-08-30 15:46:24 187

原创 leetcode:数学:Power of Two(231)

Given an integer, write a function to determine if it is a power of two.class Solution {public: bool isPowerOfTwo(int n) { if (n <= 0) { return false; } n &= (n

2016-08-30 15:22:54 300

原创 leetcode:数学:Rectangle Area(223)

https://leetcode.com/problems/rectangle-area/class Solution {public: int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { int res = (D - B) * (C - A) + (H - F) * (G -

2016-08-30 15:21:38 147

原创 leetcode:数学:Factorial Trailing Zeroes(172)

Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.class Solution {public: int trailingZeroes(int n) { int ans = 0;

2016-08-30 15:17:08 143

原创 leetcode:数学:Excel Sheet Column Numbe(171)

Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28 clas

2016-08-30 15:15:05 228

原创 leetcode:数学:Excel Sheet Column Title(168)

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example:1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB class Solution {public: string convertTo

2016-08-30 15:13:37 149

原创 leetcode:数学:Permutation Sequence(060)

The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3):“123” “132” “213” “231” “312”

2016-08-30 15:11:56 174

原创 leetcode:数学: Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.class Solution {public: bool isPalindrome(int x) { if (x < 0) return false; int bit[10]; int cnt =

2016-08-30 15:10:25 169

原创 leetcode:数学:Reverse Intege(007)

Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321class Solution {public: int reverse(int x) { long long tmp = abs((long long)x); long long

2016-08-30 15:08:54 233

原创 leetcode :Binary Search:Kth Smallest Element in a Sorted Matrix(378)

Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order, not the

2016-08-30 14:46:30 164

原创 leetcode :Binary Search: Guess Number Higher or Lower(374)

We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I’ll tell you whether the number is higher or lowe

2016-08-30 14:45:05 184

原创 leetcode :Binary Search: Valid Perfect Square(367)

Given a positive integer num, write a function which returns True if num is a perfect square else False.Note: Do not use any built-in library function such as sqrt.Example 1:Input: 16 Returns: True E

2016-08-30 14:43:06 198

原创 leetcode :Binary Search:Russian Doll Envelopes(354)

You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and height of one envelope is greater than the

2016-08-30 14:40:17 249

空空如也

空空如也

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

TA关注的人

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