自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 leetcode 567. Permutation in String

567. Permutation in StringGiven two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutations is the sub

2018-01-10 14:28:19 146

原创 leetcode 403. Frog Jump

403. Frog JumpA frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the wat

2018-01-10 10:41:32 146

原创 leetcode 343. Integer Break

343. Integer BreakGiven 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

2018-01-09 20:56:53 109

原创 leetcode 322. Coin Change

322. Coin ChangeYou are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount.

2018-01-09 19:58:31 121

原创 leetcode 326. Power of Three

326. Power of ThreeGiven an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?要求不用任何形式循环得到 一个数是不是3的阶乘1、不用循

2018-01-09 17:14:46 108

原创 leetcode 338. Counting Bits

338. Counting BitsGiven a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array

2018-01-09 17:05:17 151

原创 leetcode 365. Water and Jug Problem

365. Water and Jug ProblemYou are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measur

2018-01-09 16:48:43 158

原创 leetcode 436. Find Right Interval

436. Find Right IntervalGiven a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval i,

2018-01-09 10:47:26 149

原创 leetcode 447. Number of Boomerangs

447. Number of BoomerangsGiven n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between i and j equals the distance

2018-01-09 10:05:52 114

原创 leetcode 443. String Compression

443. String CompressionGiven an array of characters, compress it in-place.The length after compression must always be smaller than or equal to the original array.Every element of the a

2018-01-05 11:24:38 204

原创 leetcode 438. Find All Anagrams in a String

438. Find All Anagrams in a StringGiven a string s and a non-empty string p, find all the start indices of p's anagrams in s.Strings consists of lowercase English letters only and the leng

2018-01-04 14:45:54 145

原创 leetcode 450. Delete Node in a BST

450. Delete Node in a BSTGiven a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Basical

2018-01-02 19:48:43 166

原创 leetcode 441. Arranging Coins

441. Arranging CoinsYou have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.Given n, find the total number of full staircase rows that ca

2018-01-02 15:57:52 153

原创 leetcode 434. Number of Segments in a String

434. Number of Segments in a StringCount the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.Please note that the string does not contain

2018-01-02 15:50:12 140

原创 leetcode 460. LFU Cache

460. LFU CacheDesign and implement a data structure for Least Frequently Used (LFU) cache. It should support the following operations: get and put.get(key) - Get the value (will always b

2018-01-01 23:23:12 161

原创 leetcode 476. Number Complement

476. Number ComplementGiven a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is guara

2017-12-29 10:27:47 117

原创 leetcode 726. Number of Atoms

726. Number of AtomsGiven a chemical formula (given as a string), return the count of each atom.An atomic element always starts with an uppercase character, then zero or more lowercase let

2017-12-28 17:12:54 605

原创 leetcode 394. Decode String

394. Decode StringGiven an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exa

2017-12-28 16:06:22 119

原创 Effective C++之七:模板与泛型编程

条款41 了解隐式接口和编译器多态(1)面向对象的编程世界总是以显示接口以及运行期多态解决问题。//显式接口:通常由函数的签名式(函数名称、参数类型、返回类型)构成。class Widget{public:    Widget();    virtual ~Widget();    virtualsize_t size() c

2017-12-22 10:40:37 338

原创 Effective C++之六:继承与面向对象设计

条款32 确定你的public继承塑模出is-a关系(0)Derived 以 public形式 继承 base,意味着每一个类型的D的对象同时也(is-a)是一个B的对象,反之不成立。(1)public继承意味 is-a。适用于base身上的每一件事也一定适用于derived身上,因为每一个derived对象也一定是base对象。class Pers

2017-12-22 10:14:37 197

原创 Effective C++之五:实现

2017-12-21 16:03:06 137

原创 Effective C++之四:设计与声明

条款18 让接口容易被正确使用,不易被误用(1)“阻止误用”的办法包括建立新类型、限制类型上的操作,束缚对象值,以及消除客户的资源管理责任。客户可能输入错误的日子class Date{pubilc:    Date(int month,int day, int year);    ...};Date(30,3,1995

2017-12-21 15:56:10 167

原创 Effective C++之三:以对象管理资源

条款13 以对象管理资源(1)为防止资源泄露,请使用RAII(资源获取时机便是初始化时机)对象,它们在构造函数中获得资源并在析构函数中释放资源。“以对象管理资源”的观念常被称为“资源取得时机便是初始化时机”(RAII),因为我们总是在获得资源后于同一句话以它初始化(或赋值)某个管理对象。void f(){    Investment* pInv =

2017-12-21 15:40:51 186

原创 Effective C++之二:构造/析构/赋值运算

条款5 了解c++默默编写并调用了哪些函数(1)编译器可以暗自为class创建 default构造函数、copy构造函数、copy assignment操作符,以及析构函数。编译器产出的析构函数是 non-virtual的,除非这个类的基类自身声明有virtual析构函数。如果作者声明了构造函数,编译器就不会帮忙创建默认构造函数。class析构函数(无论是编

2017-12-21 14:29:45 223

原创 Effective C++之一:让自己习惯C++

0导读(1)extern int x; //加了extern是声明int x;//定义(2)隐式类型转换:从小->大的转换中。比如从char转换为int。从int->long。 自定义对象 派生类对象可以隐式转换为 基类对象。而explicit阻止隐式类型转换。 经常使用在类的构造函数前面。st

2017-12-21 10:40:47 183

原创 leetcode 383. Ransom Note

383. Ransom NoteGiven an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed

2017-12-14 20:31:53 129

原创 leetcode 376. Wiggle Subsequence

376. Wiggle SubsequenceA sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if

2017-12-13 16:40:10 155

原创 leetcode 380. Insert Delete GetRandom O(1)

380. Insert Delete GetRandom O(1)Design a data structure that supports all following operations in average O(1) time.insert(val): Inserts an item val to the set if not already present.

2017-12-13 15:35:46 157

原创 leetcode 392. Is Subsequence

392. Is SubsequenceGiven a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long

2017-12-13 14:43:53 138

原创 C++排序算法代码汇总

排序算法稳定性:两个相同的元素排序前后的相对位置关系不会发生改变。复杂度比较算法平均时间复杂度最好情况最坏情况空间复杂度稳定性冒泡排序O(N^2)O(N^2)O(N^2)O(1)稳定插入排序O(N^2)O(N)O(N^2)O(1)稳定选择排序O(N^2)O(N^2)O(N^2)O(1)稳定希尔排序O(N ^ 3/2 ) O(N^2)O(1)不稳定堆排序O(NlogN)O(NlogN)O(NlogN...

2017-12-07 20:34:52 14650

原创 leetcode 372. Super Pow

372. Super PowYour task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.Example1:a = 2b = [3]Res

2017-12-06 20:31:58 133

原创 leetcode 371. Sum of Two Integers

371. Sum of Two IntegersCalculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.网上看的思路,非常强大。

2017-12-06 19:52:33 135

原创 leetcode 368. Largest Divisible Subset

368. Largest Divisible SubsetGiven a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0

2017-12-06 19:19:54 127

原创 leetcode 523. Continuous Subarray Sum 560. Subarray Sum Equals K

下面两个题都是使用了unordered_map数组的 连续子数组和 满足什么条件的问题。523. Continuous Subarray SumGiven a list of non-negative numbers and a target integer k, write a function to check if the array has a contin

2017-12-05 16:06:18 182

原创 leetcode 398. Random Pick Index

398. Random Pick IndexGiven an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array

2017-12-05 14:28:07 138

原创 leetcode 382. Linked List Random Node

382. Linked List Random NodeGiven 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 li

2017-12-05 11:26:36 152

原创 leetcode 319. Bulb Switcher

319. Bulb SwitcherThere 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

2017-12-05 10:54:08 132

原创 leetcode 292. Nim Game

292. Nim GameYou 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 las

2017-12-05 10:33:09 135

原创 leetcode 374. Guess Number Higher or Lower

374. Guess Number Higher or LowerWe 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 wh...

2017-12-05 10:12:09 118

原创 leetcode 464. Can I Win

464. Can I WinIn the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins. What if

2017-12-05 09:34:03 310

空空如也

空空如也

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

TA关注的人

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