自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Leetcode 169 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 that the array is non-empty and the majority

2016-03-30 19:05:08 215

原创 LeetCode 217 Contains Duplicate

题目:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every eleme

2016-03-30 17:49:10 298

原创 LeetCode 231 Power of Two(三解)

231. Power of TwoGiven an integer, write a function to determine if it is a power of two.我的方法是暴力求解,循环让1一直乘以2,如果结果等于n,且n大于0则输出true。这是最容易想到的方法class Solution {public: bool isPowerOfTwo(int

2016-03-28 23:37:34 314

原创 LeetCode 191 number of 1 bits

Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 000000

2016-03-28 23:17:37 283

原创 Leetcode 120 Triangle(图解)

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent(相邻的) numbers on the row below.For example, given the following triangle[ [2], [3,4],

2016-03-26 10:40:36 444

原创 算法导论 动态规划之钢条切割

#include#includeusing namespace std;int UpToBottom(int *p,int n)//普通的自顶向下实现{ if (n == 0) return 0; int q = -1; for (int i = 1; i <= n; i++) { q = max(q, p[i]+UpToBottom(p, n - i)); } re

2016-03-25 13:47:02 548

原创 LeetCode137 Single Number II

question:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement i

2016-03-21 10:16:00 297

原创 LeetCode 202 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 integer, replace the number by the sum of the squares

2016-03-16 19:59:12 360

原创 LeetCode 258. 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 process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on

2016-03-15 22:15:31 311

原创 LeetCode 136 single number

题目:给定一个数组,每个元素都出现2次除了其中的一个,找出只出现一次的数字注意:算法必须是线性时间复杂度,不使用额外的空间。提示:利用亦或运算的性质。#include#includeusing namespace std;int single(vector&num){//A XOR A =0; int result = 0; for (int i = 0; i != num

2016-03-14 21:01:41 234

原创 Leetcode266 Palindrome Permutation

QuestionGiven a string, determine if a permutation of the string could form a palindrome.For example, “code” -> False, “aab” -> True, “carerac” -> True.Hint:Consider the palindromes

2016-03-14 11:32:45 325

空空如也

空空如也

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

TA关注的人

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