自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

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

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

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

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

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

2017-12-21 10:40:47 184

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

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

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

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

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

原创 leetcode 486. Predict the Winner

486. Predict the WinnerGiven an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so o

2017-12-04 21:40:21 149

原创 leetcode 329. Longest Increasing Path in a Matrix

329. Longest Increasing Path in a MatrixGiven an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or dow

2017-12-04 21:21:44 138

原创 leetcode 621. Task Scheduler

621. Task SchedulerGiven a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original

2017-12-04 15:49:19 251

原创 leetcode 493. Reverse Pairs

493. Reverse PairsGiven an array nums, we call (i, j) an important reverse pair if i  and nums[i] > 2*nums[j].You need to return the number of important reverse pairs in the given array.

2017-12-04 14:38:08 242

原创 leetcode 698. Partition to K Equal Sum Subsets

698. Partition to K Equal Sum SubsetsGiven an array of integers nums and a positive integer k, find whether it's possible to divide this array into k non-empty subsets whose sums are all equ

2017-12-04 10:30:04 193

原创 leetcode 687. Longest Univalue Path

687. Longest Univalue PathGiven a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.Note: The le

2017-12-04 10:01:16 373

原创 leetcode 699. Falling Squares

699. Falling SquaresOn an infinite number line (x-axis), we drop given squares in the order they are given.The i-th square dropped (positions[i] = (left, side_length)) is a square with the left-most p...

2017-12-02 18:23:46 568

原创 leetcode 307. Range Sum Query - Mutable

307. Range Sum Query - MutableGiven an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by updating the element at ...

2017-12-01 10:11:37 157

空空如也

空空如也

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

TA关注的人

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