自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LeetCode 514. 自由之路

514.自由之路目录思路代码复杂度分析思路构建一个映射表,记录ring中每个下标向前向后到达每个字母的距离。然后BFS枚举,只枚举当前位置向前向后的到达目标字符,并记录。枚举的时候采用了一些小优化,map的重复使用,以及只记录需要遍历的pos等等。代码func findRotateSteps(ring string, key string) int { ...

2019-06-04 15:59:19 265

转载 windows8系统 出现不能关机和重启 但是能够休眠的问题

我猜测我的原因如下昨天帮同学考资料,用了他的移动硬盘,然后出现了该磁盘卷有问题的提示,当时也没怎么管他,后来晚上关机的时候就出现不能关机,不能重启, 但是可以休眠的问题。使用命令关机 也是不行的。后来在网上看到一篇博客, http://bbs.pcbeta.com/viewthread-1271648-1-1.html大概意思是执行关机命令的时候,会进行磁盘检测,然后磁

2015-11-10 17:40:23 474

原创 百度面试

16号去的成都面试还没进去前有点紧张,进去后也就没什么了。感觉自己一面都没过 还是有点low,(其实感觉挺好的(自我感觉良好,))感觉很年轻的一个小哥,一进来就先让我自我介绍,大概用了30秒然后就开始问问题第一个问题是,进程和线程的区别,这个百度一下就知道了,很简答第二个问题 是给了我一张双向链表,让我在某一个位置插入一个节点。我

2015-09-17 21:16:54 429

原创 这几天遇到的一些面试题

1.有8瓶药,只有唯一的一瓶药有效果,生效时间为两小时,如何用最少的试药人在两小时内找到这瓶药。首先想到的是最多肯定是7个人。然后看题大概是一个人要吃几瓶药,才能减少人数,排列组合?通过几次试着写,发现4个人可以解决,在写的时候感觉有点像组合大概就是不同人的组合标记一种药,人数的不同的不同组合。然后就想到了二项式分布。 8 = 2^3 = C(0,3) + C(1,3) + C(2,

2015-09-08 21:30:08 317

原创 c++模版元编程

编译时计算阶乘#includeusing namespace std;templateclass Factorial{public: enum{ value = n * Factorial::value };};template<>class Factorial{public: enum{ value = 1 };};int main(){ cout ::v

2015-09-04 11:58:17 349

原创 C++11 - lambda

使用lambda可以编写匿名的内嵌函数语法[capture_block](parameters)mutable exception_specification ->return_type{body}capture_block:捕捉块,指定如何从作用域捕捉变量例如&,按照引用捕捉=,按照值捕捉&,a, 除a按值捕捉,其他按引用捕捉=,&a,除a按引用捕捉,

2015-09-02 13:20:39 339

原创 LeetCode-Integer to English Words-解题报告

原题链接 https://leetcode.com/problems/integer-to-english-words/Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example,

2015-09-02 11:51:31 531

原创 LeetCode-Binary Tree Paths -解题报告

原题链接 https://leetcode.com/problems/binary-tree-paths/Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5

2015-08-29 23:55:29 252

原创 LeetCode-Add Digits-解题报告

原题链接 https://leetcode.com/problems/add-digits/Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the proces

2015-08-29 18:58:02 300

原创 LeetCode-Single Number-解题报告

原题链接 https://leetcode.com/problems/single-number/Given an array of integers, every element appears twice except for one. Find that single one.找出唯一一个只出现一次的数。因为其他数肯定出现两次 又因为A^A = 0, 0^B = B;所以

2015-08-28 18:55:51 252

原创 LeetCode-Ugly Number-解题报告

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

2015-08-28 16:41:49 287

原创 LeetCode-Ugly Number II-解题报告

原链接https://leetcode.com/problems/ugly-number-ii/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,

2015-08-28 15:52:15 289

原创 LeetCode-Missing Number-解题报告

原题链接 https://leetcode.com/problems/missing-number/Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given n

2015-08-27 16:16:05 343

原创 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 312

原创 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 453

原创 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 1442

原创 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 509

原创 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 251

原创 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 418

原创 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 262

原创 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 301

原创 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 251

原创 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 332

原创 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 258

原创 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 483

原创 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 323

原创 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 288

原创 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 222

原创 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 248

原创 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 454

原创 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 395

原创 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 245

原创 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 273

转载 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 371

原创 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 291

原创 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 237

原创 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 333

原创 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 292

原创 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 346

原创 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 562

空空如也

空空如也

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

TA关注的人

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