自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(50)
  • 收藏
  • 关注

原创 LeetCode-Lowest Common Ancestor of a Binary Search Tree-解题报告

原题链接 https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.Accordin

2015-07-20 17:43:17 319

原创 LeetCode-Palindrome Linked List-解题报告

原题链接 https://leetcode.com/problems/palindrome-linked-list/Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?判断一个链表是否回文,O(n

2015-07-20 16:36:38 464

原创 LeetCode-Number of Digit One-解题报告

原题链接 https://leetcode.com/problems/number-of-digit-one/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

2015-07-09 14:04:11 1472

原创 LeetCode-Two Sum-解题报告

原题链接 https://leetcode.com/problems/two-sum/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 num

2015-07-08 21:32:42 514

原创 LeetCode-Add Two Numbers-解题报告

原题链接 https://leetcode.com/problems/add-two-numbers/You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a si

2015-07-08 21:31:09 261

原创 LeetCode-Median of Two Sorted Arrays-解题报告

原题链接 https://leetcode.com/problems/median-of-two-sorted-arrays/There are two sorted arrays nums1 andnums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run ti

2015-07-08 21:29:02 427

原创 LeetCode-Reverse Integer-解题报告

原题链接 https://leetcode.com/problems/reverse-integer/Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321 class Solution {public:    int reverse(int x) {

2015-07-08 21:26:43 270

原创 LeetCode-String to Integer (atoi) -解题报告

原题链接 https://leetcode.com/problems/string-to-integer-atoi/Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do n

2015-07-08 21:25:59 308

原创 LeetCode-Permutations-解题报告

原题链接 https://leetcode.com/problems/permutations/Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3]

2015-07-08 21:07:48 256

原创 LeetCode-Pow(x, n)-解题报告

原题链接 https://leetcode.com/problems/powx-n/Implement pow(x, n). 以前在算法书中看到过一个,将指数n写成2进制的情况。比如2^5 = 2^101 = 2^3 * 2^1class Solution {public: double myPow(double x, int n) { doubl

2015-07-08 21:02:57 342

原创 LeetCode-Add Binary-解题报告

原题链接 https://leetcode.com/problems/add-binary/Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100". 很简单和做大数加法一样的做法class Solut

2015-07-08 21:00:37 264

原创 LeetCode-Sqrt(x)-解题报告

原题链接 https://leetcode.com/problems/sqrtx/Implement int sqrt(int x).Compute and return the square root of x.用数学的方法求解sqrt(x)可以使用牛顿迭代法,也可以使用二分法。我使用的是牛顿迭代法,前段时间看到一个求解x^(-2)的快速解就用的是牛顿迭代

2015-07-08 20:55:59 496

原创 LeetCode-Subsets-解题报告

原题链接 https://leetcode.com/problems/subsets/Given a set of distinct integers, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set

2015-07-08 19:59:25 332

原创 LeetCode-Unique Binary Search Trees-解题报告

原题链接 https://leetcode.com/problems/unique-binary-search-trees/Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a tot

2015-07-08 19:36:09 296

原创 LeetCode-Binary Tree Level Order Traversal-解题报告

原题链接 https://leetcode.com/problems/binary-tree-level-order-traversal/Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For exam

2015-07-08 19:34:16 233

原创 LeetCode-Rotate Array-解题报告

原题链接 https://leetcode.com/problems/rotate-array/Rotate an array of n elements to the right byk steps.For example, with n = 7 and k = 3, the array[1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]

2015-07-08 19:25:36 256

原创 LeetCode-Reverse Bits-解题报告

原题链接 https://leetcode.com/problems/reverse-bits/Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), ret

2015-07-08 19:22:04 465

原创 LeetCode-Number of 1 Bits-解题报告

原题链接 https://leetcode.com/problems/number-of-1-bits/Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the

2015-07-08 19:19:58 404

原创 LeetCode-Binary Tree Right Side View-解题报告

原题链接 https://leetcode.com/problems/binary-tree-right-side-view/Given a binary tree, imagine yourself standing on theright side of it, return the values of the nodes you can see ordered from top

2015-07-08 19:15:53 255

原创 LeetCode-Number of Islands-解题报告

原题链接 https://leetcode.com/problems/number-of-islands/Given a 2d grid map of '1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting

2015-07-08 19:13:51 284

转载 LeetCode-Bitwise AND of Numbers Range-解题报告

原题链接 https://leetcode.com/problems/bitwise-and-of-numbers-range/Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4. 返回m-n之间的数字做&操作的值我是在网上看到的一个做法,由于

2015-07-08 19:08:09 383

原创 LeetCode-Happy Number-解题报告

原题链接 https://leetcode.com/problems/happy-number/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 int

2015-07-08 19:01:10 306

原创 LeetCode-Remove Linked List Elements-解题报道

原题链接https://leetcode.com/problems/remove-linked-list-elements/Remove all elements from a linked list of integers that have valueval.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val =

2015-07-08 18:49:44 244

原创 LeetCode-Count Primes-解题报告

原题链接 https://leetcode.com/problems/count-primes/Description:Count the number of prime numbers less than a non-negative number,n.数素数有多少个。方法可以用一般的方法,就是判断从1-sqrt(n) 有没有能够整除的数。当然可以排除

2015-07-08 18:41:55 347

原创 LeetCode-Reverse Linked List-解题报告

原题链接 https://leetcode.com/problems/reverse-linked-list/Reverse a singly linked list.反转链表水过。/** * Definition for singly-linked list. * struct ListNode { * int val; * L

2015-07-08 18:36:37 303

原创 LeetCode-Course Schedule-解题报告

原题链接 https://leetcode.com/problems/course-schedule/There are a total of n courses you have to take, labeled from0 to n - 1.Some courses may have prerequisites, for example to take course 0 you

2015-07-08 18:28:33 354

原创 LeetCode-Minimum Size Subarray Sum-解题报告

原题链接 https://leetcode.com/problems/minimum-size-subarray-sum/Given an array of n positive integers and a positive integers, find the minimal length of a subarray of which the sum ≥ s. If there

2015-07-08 18:12:41 573

原创 LeetCode-Course Schedule-解题报告

原题链接 https://leetcode.com/problems/course-schedule/There are a total of n courses you have to take, labeled from0 to n - 1.Some courses may have prerequisites, for example to take course 0 you

2015-07-08 18:09:44 311

原创 LeetCode-Min Stack-解题报告

原题链接https://leetcode.com/problems/min-stack/Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack. pop() -- Re

2015-07-07 16:01:28 331

原创 LeetCode-Implement Queue using Stacks-解题报告

原题链接https://leetcode.com/problems/implement-queue-using-stacks/Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue. pop() -- Removes t

2015-07-07 15:58:18 459

原创 LeetCode-Power of Two-解题报告

原题链接https://leetcode.com/problems/power-of-two/Given an integer, write a function to determine if it is a power of two.直接看所给整数中位中1的个数 超过2个 就不是2的幂class Solution {public: bool isPow

2015-07-06 18:31:28 276

原创 LeetCode-Compare Version Numbers解题报告

原题链接https://leetcode.com/problems/compare-version-numbers/Compare two version numbers version1 andversion2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.

2015-07-06 18:23:52 330

原创 LeetCode-Fraction to Recurring Decimal-解题报告

原题链接https://leetcode.com/problems/fraction-to-recurring-decimal/Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractiona

2015-07-03 19:48:00 346

原创 LeetCode-Majority Element -解题报告

原题链接https://leetcode.com/problems/majority-element/Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume th

2015-07-03 18:42:30 447

原创 LeetCode-Excel Sheet Column Number-解题报告

原题链接https://leetcode.com/problems/excel-sheet-column-number/Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number

2015-07-03 18:31:29 311

原创 LeetCode-Excel Sheet Column Title-解题报告

原题链接https://leetcode.com/problems/excel-sheet-column-title/Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -

2015-07-03 17:59:23 336

原创 LeetCode-Factorial Trailing Zeroes-解题报告

原题链接https://leetcode.com/problems/factorial-trailing-zeroes/Given an integer n, return the number of trailing zeroes inn!.Note: Your solution should be in logarithmic time complexity.求n!的尾部有

2015-07-03 16:56:11 267

原创 LeetCode-Binary Search Tree Iterator-解题报告

原题链接https://leetcode.com/problems/binary-search-tree-iterator/Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next()

2015-07-03 15:43:19 351

原创 LeetCode-Largest Number-解题报告

原题链接https://leetcode.com/problems/largest-number/Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest form

2015-07-02 19:35:42 311

原创 LeetCode-Repeated DNA Sequences -解题报告

原题链接https://leetcode.com/problems/repeated-dna-sequences/All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes

2015-07-02 16:48:38 250

空空如也

空空如也

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

TA关注的人

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