自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 leetcode 206. Reverse Linked List

Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLclass Solution {public: ListNode* reverseList(ListNode* head) { ...

2018-12-21 20:12:05 88

原创 leetcode 204. Count Primes 计算质数的数目

Count the number of prime numbers less than a non-negative number, n.Example:Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.常规方法很容易超时,要使用高效的算法,这是googl...

2018-12-21 19:23:37 112

原创 leetcode 203. Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.Example:Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4->5 Accepted增加头节点,以防止溢出class S...

2018-12-21 18:19:54 82

原创 leetcode 198. House Robber

House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that ...

2018-12-21 17:49:57 82

原创 leetcode 202. Happy Number

Happy NumberWrite an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of...

2018-12-21 17:48:48 101

原创 leetcode 189. Rotate Array

Given an array, rotate the array to the right by k steps, where k is non-negative.感觉难度不大,但是注释的两句改了好久才改好,还是水平太低class Solution {public: void rotate(vector<int>& nums, int k) { i...

2018-12-18 19:28:24 85 1

原创 leetcode 172. Factorial Trailing Zeroes乘方后面带几个零

Factorial Trailing Zeroes问n的乘方后面带几个零,这是数学题,重点在于因数中有几个10,也就是有几个2和5,而5比2要稀缺得多所以找到因数中一共是几个5就可以了。我的代码class Solution {public: int trailingZeroes(int n) { int ret=0; while(n=n/5)...

2018-12-18 17:50:17 78

原创 Boyer-Moore Voting Algorithm 多数投票算法

Boyer-Moore Voting Algorithm 多数投票算法##Majority Element题目介绍:给定一个长度为n的数组的时候,找出其中的主元素,即该元素在数组中出现的次数大于n/2的取整。题目中已经假定所给的数组一定含有元素,且主元素一定存在。在刷leetcode 169. Majority Element 的时候发觉这个算法相当巧妙,hash表的找主成分方法时间复杂度是O...

2018-12-18 17:29:13 325

空空如也

空空如也

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

TA关注的人

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