自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

魔豆(Magicbean)的博客

分享计算机专业的相关知识

  • 博客(13)
  • 收藏
  • 关注

转载 [C++] 编程实践之1: Google的C++代码风格4:来自Google的奇技

来自Google的奇技  Google用了很多自己实现的技巧/工具使C++代码更加简装,我们使用C++的方式可能和你在气他地方见到的有所不同。所有权与智能指针 动态分配出的对象最好有单一且固定的所有主(owner),且通过智能指针传递所有权(ownership)。定义:所有权是一种登记/管理动态内存和其它资源的技术。动态分配出的对象的所有主是一个对象或者函数,后者负责确保当前者无用时就自动销

2017-02-28 16:09:40 528

转载 [C++] 编程实践之1: Google的C++代码风格3:类

类  类是C++中代码的基本单元。显然它们被广泛使用。本节列举了在写一个类时的主要注意事项。构造函数的职责 不要在构造函数中进行复杂的初始化(尤其是那些有可能失败或者需要调用虚函数的初始化)。定义:在构造函数体中进行初始化操作。优点:排版方便,无需担心类是否已经初始化。缺点:构造函数中很难上报错误,不能使用异常。操作失败会造成对象初始化失败,进入不确定状态。如果在构造函数内调用了

2017-02-27 15:32:31 1326

转载 [C++] 编程实践之1: Google的C++代码风格2:作用域

2. 作用域2.1 名字空间 鼓励在.cc文件内使用匿名名字空间。使用具名的名字空间时,其名称可基于项目名或者相对路径。禁止使用using指示(using-directive)。禁止使用内联命名空间(inline namespace)。定义:名字空间将全局作用域细分为独立的,具名的作用域,可有效防止全局作用域的命名冲突。优点:虽然类已经提供了(可嵌套的)命名

2017-02-27 09:44:32 517

转载 [C++] 编程实践之1: Google的C++代码风格1:头文件

作为使用最为广泛的语言之一,C++也出现在众多开源项目中。为了有效管理C++丰富的语法所带来的复杂性和提高可读性,Google公司专门制定了C++代码风格建议。为了便于自己养成良好的编程习惯,同时为国内同行提供便利,我将原文内容以及对应的中文翻译做一个精简版的总结。1. 头文件  通常而言,每个.cc(.cpp)文件应该对应一个.h头文件,但也有例外,例如包含main()函数的文件。本小节

2017-02-27 09:39:04 540

原创 [Leetcode] 82. Remove Duplicates from Sorted List II 解题报告

题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Gi

2017-02-09 09:47:59 345

原创 [Leetcode] 81. Search in Rotated Sorted Array II 解题报告

题目:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose an array sorted in ascending order is

2017-02-09 09:21:53 454

原创 [Leetcode] 80. Remove Duplicates from Sorted Array II 解题报告

题目:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the

2017-02-04 16:33:58 322

原创 [Leetcode] 79. Word Search 解题报告

题目:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or v

2017-02-04 16:08:50 409

原创 [Leetcode] 78. Subsets 解题报告

题目:Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:[ [3

2017-02-04 15:33:26 308

原创 [Leetcode] 77. Combinations 解题报告

题目:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3],

2017-02-04 15:05:35 401

原创 [Leetcode] 76. Minimum Window Substring 解题报告

题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum windo

2017-02-04 01:46:15 388

原创 [Leetcode] 75. Sort Colors 解题报告

题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the

2017-02-04 01:02:57 340

原创 [Leetcode] 74. Search a 2D Matrix 解题报告

题目:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first intege

2017-02-04 00:38:25 364

空空如也

空空如也

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

TA关注的人

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