自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

AllZone

Work It Harder Make It Better Do It Faster Makes Us Stronger

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

原创 [LeetCode] Find Minimum in Rotated Sorted Array 题解

前言Find Minimum in Rotated Sorted Array这道题存在的价值,大概就是让大家直观感受一下LeetCode上二分的题目真的很多。。。题目https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/ Suppose a sorted array is rotated at some pivot u

2016-04-28 20:58:19 498

原创 Android的基本世界观——系统简介,组件逻辑及其他

作为一个有半年余Android Developing折腾经验的Android Developer(为什么不说“开发经验”呢?因为我仔细想了想,我还没有独立地做出一个完善美观且有使用价值的应用。),要系统地学习安卓平台的基本开发技能,那么第一步,了解并熟识Android的基本世界观,应该就是十分必要的了。以前这方面的知识体系不成系统,比较破碎零散,故借此文稍作整理。

2016-03-31 22:34:46 1528 1

原创 如何求二进制表示中“1”的个数

刚翻开《编程之美》, 中间就有一道我很眼熟的题,“求二进制中1的个数”。书中的题目描述如下:

2016-03-21 18:46:21 844

原创 [LeetCode] Insertion Sort List

前言Insertion Sort List算是Linked List tag下的一道中等难度的题吧,可以用来复习链表的选择排序操作。解法很固定,没什么讨论的余地。题目https://leetcode.com/problems/insertion-sort-list/ Sort a linked list using insertion sort. 排序一个链表,指定必须采用插入排序算法。分析插入

2016-03-19 21:30:02 333

原创 [LeetCode] Intersection of Two Linked Lists 题解

Intersection of Two Linked Lists也是LeetCode的Linked List Tag下的一道题,网上流传着多种做法。

2016-03-19 11:00:27 390

原创 [LeetCode] Valid Anagram 题解

前言题目https://leetcode.com/problems/valid-anagram/Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t

2016-03-18 10:53:55 406

原创 [LeetCode] Missing Number

前言Missing Number是一道和Single Number很像的题(无论是从名字还是解法的角度而言),具体思路并不难,做法倒是不少。题目https://leetcode.com/problems/missing-number/ Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the on

2016-03-17 20:57:53 421

原创 [LeetCode] Single Number & Single Number III

Single Number三步曲是LeetCode诸多系列题中流传最广的一个(也许没有之一?),这里放在一起讨论一下。由于Single Number II稍微难一些,所以这篇文章先讨论I和III。

2016-03-16 08:06:46 401

原创 [LeetCode] Validate Binary Search Tree

前言根据网上的LeetCode题目难度和出现频率表(里面都是最老的那些题目),Validate Binary Search Tree算是很重要的一道题了。 在Tree系列中也是举足轻重的一道题。题目https://leetcode.com/problems/validate-binary-search-tree/ Given a binary tree, determine if it is a

2016-03-10 21:43:48 312

原创 [LeetCode] Set Matrix Zeroes

前言Set Matrix Zeroes,一道LeetCode中十分经典的数组题,据说在笔试中出现频率不低。不过此题本质不难,要做到不适用额外空间就稍微要多想一下了。题目https://leetcode.com/problems/set-matrix-zeroes/ Given a m x n matrix, if an element is 0, set its entire row and co

2016-03-09 20:47:50 381

原创 [LeetCode] 3Sum分析与C/C++解法

前言3Sum算是LeetCode最经典的十几道题之一了,据说在面试中出现的频率相当高。所以在这里花点篇幅讨论一下此题。题目https://leetcode.com/problems/3sum/ Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all uniqu

2016-03-08 21:23:37 1032

原创 [LeetCode] Plus One 简要分析

前言Plus one是一道数组相关的题,其实就是高精度加法。题目https://leetcode.com/problems/plus-one/ Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most

2016-03-08 13:09:06 327

原创 [LeetCode] Linked List Cycle 与 Linked List Cycle II

前言Linked List Cycle 与 Linked List Cycle II是LeetCode链表系列很经典的两道题,值得研究一下。题目https://leetcode.com/problems/linked-list-cycle/ https://leetcode.com/problems/linked-list-cycle-ii/Linked List CycleGiven a lin

2016-03-07 14:37:13 294

原创 [LeetCode] Bulb Switcher

前言Bulb Switcher是LeetCode上的一道”脑筋急转弯”类题目,颇有趣味性。难度并不大,实际上想通数学规律后,此题只需要一行代码。题目https://leetcode.com/problems/bulb-switcher/ There are n bulbs that are initially off. You first turn on all the bulbs. Then,

2016-03-06 10:39:04 308

原创 [LeetCode] Binary Tree Traversal 系列

前言LeetCode有三道考察二叉树遍历的基础题,即Binary Tree XXXOrder Traversal 系列,分别为Preorder,inorder,以及postorder。 先序,中序,后序遍历都比较简单,下面讨论递归方法。题目https://leetcode.com/problems/binary-tree-preorder-traversal/ https://leetcode.

2016-03-04 12:28:35 283

原创 [LeetCode] House Robber 题解

前言House Robber算是LeetCode动态规划tag下的入门题,相当简单。题目题目链接:https://leetcode.com/problems/house-robber/ You are a professional robber planning to rob houses along a street. Each house has a certain amount of mon

2016-03-03 14:57:06 501

原创 Android Studio的Git与Github配置

前言Android Studio是当前最为流行的安卓开发工具(等到彻底取代Eclipse之后这一点就更毋庸置疑了),而Git是世界上最popular的分布式版本管理系统,至于Github,则是目前最受欢迎的开源社区。三者配合使用将大大提高开发生产力。安装想要在AS中使用Git工具,首先需要保证你的PC端已经安装了Git(想要了解Git使用,这里有一个不错的Git入门“游戏”)。我的Git是下载Git

2016-03-03 10:11:08 1773

原创 [LeetCode] Unique Paths 题解

前言Unique Paths应该说是LeetCode动态规划系列中很亲民的一道题了(AC率比较高)。实际上,Dynamic Programming的题目一般关键都在于想出递推关系,成功写出准确的循环解法。题目题目链接:https://leetcode.com/problems/unique-paths/ A robot is located at the top-left corner of a

2016-03-02 18:03:15 568

原创 [LeetCode] Balanced Binary Tree 题解

前言LeetCode blabla Tree系列稍微不太水的一道题,很有使用价值(可以牵扯到AVL树的概念什么的)。递归仍然是不二选择。题目https://leetcode.com/problems/balanced-binary-tree/ Given a binary tree, determine if it is height-balanced. For this problem, a

2016-03-02 08:56:00 283

原创 [LeetCode] Maximum Depth of Binary Tree

前言LeetCode 的blabla Tree系列又一基础题,可配合 Minimum Depth of Binary Tree 一起练习。题解在此。题目https://leetcode.com/problems/maximum-depth-of-binary-tree/ Given a binary tree, find its maximum depth. The maximum depth

2016-03-01 21:33:35 323

原创 [LeetCode] Minimum Depth of Binary Tree

前言LeetCode 的blabla Tree系列的又一道题,Recursive solution很好理解。题目https://leetcode.com/problems/minimum-depth-of-binary-tree/ Given a binary tree, find its minimum depth. The minimum depth is the number of nod

2016-03-01 21:21:44 302

原创 [LeetCode] Same Tree

前言Leetcode之blabla Tree系列的一道水题。题目https://leetcode.com/problems/same-tree/分析仍然是两种基本思路——递归与非递归,递归比较容易理解。具体见代码。代码Recursive solution, easy to understand.bool isSameTree(TreeNode* p, TreeNode* q) { if (!

2016-02-29 22:58:42 284

原创 [LeetCode] Symmetric Tree

前言一道树相关的简单题,判断二叉树是否对称。题目https://leetcode.com/problems/symmetric-tree/ Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).分析这类题一般都有递归和非递归两种基本思路。对于此题而言,递归方式相对e

2016-02-29 22:06:20 315

原创 [数据结构与算法分析] 二叉查找树的基础概念,插入以及删除

前言二叉查找树(Binary Search Tree,又叫二叉搜索树,二叉排序树)是这样的一种数据结构:它或者是一棵空树,或者是具有下列性质的二叉树:若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值;若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值;它的左、右子树也分别为二叉排序树。 BST被称为二叉排序树的原因就在于树中所有的元素都可以用某种统一的方式排序(假设运算

2016-02-12 13:21:59 470

原创 [LeetCode] Valid Parentheses

前言Valid Parentheses是Leetcode的一道基础题,考察括号匹配算法,使用栈结构。题目题目描述Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets must close in

2016-02-07 09:20:33 222

原创 栈的简单实现——使用C++容器库(STL Stack)

前言作为比较简单的数据结构,使用C++容器库中的栈(std::stack)也相对比较简单。 在头文件中,栈的定义为:template< class T, class Container = std::deque<T>> class stack;Stack常用函数:top():访问栈顶empty():判断栈空size():返回栈中元素数push():向栈顶插入元素pop(

2016-02-06 12:28:22 449

原创 表的简单实现——使用C++容器库(STL List)

前言表(List)和栈(Stack)是最基础最简单的数据结构,为此,C++提供了现成的库(std::list与std::stack),其使用方法也比较简便。简介list和stack在头文件中分别定义为:template< class T, class Allocator = std::allocator<T>> class list;以及template< class T,

2016-02-05 12:58:25 516

原创 [数据结构与算法分析] 栈的数组实现

前言栈的实现比较简单,提前声明一个数组作为元素的存储空间即可。不过这就要求代码中有满栈检查,以免发生数组越界。因为现代计算机系统将栈操作作为指令结构的一部分,所以栈可能是仅次于数组的最基本的数据结构。代码整体代码比较简单,只需注意TopOfStack这个索引值的用法即可。.h中的声明:#ifndef ARRAYSTACK_H_INCLUDED#define ARRAYSTACK_H_INCLUDE

2016-02-04 11:05:21 340

原创 [数据结构与算法分析] 栈的链表实现

前言栈是一种较为简单而基础的数据结构,又叫LIFO(Last In Fisrt Out)表,也可以看做是一种限制插入和删除只能在一个位置上进行的表(这个位置就称为栈顶)。 栈的操作也很简单,大概就是Push, Pop和Top(有时叫GetTop)这几种操作。 这里采用单链表来实现栈,除此之外还可以用数组实现。代码.h文件声明:#ifndef LINKSTACK_H_INCLUDED#defin

2016-02-03 15:55:12 335

原创 [数据结构与算法分析] 链表的游标实现

Weiss书中提到了链表的游标实现,什么是游标(Cursor)实现呢?诸如BASIC和FORTRAN等许多语言都不支持指针。如果需要链表而又不能使用指针,这时我们可以使用游标(cursor)实现法来实现链表。在链表的实现中有两个重要的特点:1,数据存储在一组结构体中。每一个结构体包含有数据以及指向下一个结构体的指针。2,一个新的结构体可以通过调用malloc而从系统全局内存(g

2016-02-02 14:03:23 1187

原创 [数据结构与算法分析] 单链表基本操作的实现

这几天还在啃Weiss书的Ch.3,随手把书上单链表基本操作的代码打了一遍,顺便补充了一点自己写的东西(一堆注释以及几个函数),经过测试应该是没问题。  这次尝试用所谓的"Google Style"写代码,习惯了缩进4空格的Windows风格后再改到缩进2空格,真的是有些不习惯。本来Google Style中,变量应该都是小写字母,但我实在不喜欢小写的L和P,变量命名仍就坚持自己的习惯——单字

2016-02-02 14:03:18 639

原创 [数据结构与算法分析] 求连续子数组的最大和问题

前言  这几天一直在读Weiss的数据结构书(Data Structures and Algorithm Analysis in C:Second Edition),其中第二章是关于简单的算法分析(引入大O记号等工具),以“求连续子数组的最大和问题”为例,进行了一些说明和阐释。最大子数组和问题(原书翻译为“最大的子序列和问题”)实际上我去年夏天暑假在家刷学院OJ的时候就见过,后来秋天开算法课,

2016-02-02 14:03:09 520

原创 [LeetCode] Remove Element 分析

Remove Element算是LeetCode的一道水题,不过这题也有多种做法,现就我所知的几种做一点讨论。题目链接:https://leetcode.com/problems/remove-element/ 题目描述:Given an array and a value, remove all instances of that value in place and return th

2016-02-02 14:03:05 441

原创 浅谈“be practical and realistic”

一  “实事求是”这个词,一般认为是古人的一种治学观念,后来经咏芝的发明、阐释、以及“应用”,成为“基本思想路线”(具体可参看大学思想政治教科书),被称为“活的灵魂”。这里不想过多地牵扯政治话题,仅就我这几个月的一些阅读、理解和思考,对于“实事求是”及其所代表的实践观,认识论,以及处事思想,作一些初步的,浅薄的讨论。另外,对于这四个字的翻译,历来无甚定论。这里采用“be practical a

2016-02-02 14:03:00 2659

原创 [LeetCode] Remove Duplicates from Sorted Array

前言Remove Duplicates from Sorted Array是比较平易近人的一道题,做的时候直接模拟AC,后来在网上看到有STL做法,利用现成的函数和工具就是简便啊。题目题目链接描述如下:Given a sorted array,remove the duplicates in place such that each element ap

2016-02-02 12:39:16 497

原创 Github上如何取消fork别人的repository

在Github上如果看到有很不错的项目和作品,一般我们可以进行三种操作:那就是watch, star和fork.Watch也就是关注该repo的动态,star则类似于Facebook和Twitter上的”like”,fork就是将别人的项目拷贝一份给自己,new一个新的分支(Branch)出来,你push的改进和补充则又由原作者选择是否接受。关于这些基本概念和操作,知乎的这个回答相当详尽生动。现在的

2015-12-14 23:36:11 56030 3

原创 关于CodeBlocks中stdc++-6.dll缺失的小问题

前一阵子在用CodeBlocks刷OJ(也并不是什么很难的算法,背包问题而已)时,遇到了个小麻烦,按下F9编译运行(有的人习惯用鼠标去点那个小button,多麻烦啊)后,Windows给我跳出个小窗说是stdc++-6.dll缺失,意思是让我修复一下这个文件。这个文件不难找,随便搜一下就能下到。但问题是下完了放哪?看了看网上的建议,貌似应该放到C盘的system32里面。我按照这个来了,尝试编译运行

2015-12-12 15:32:20 3317 1

原创 [LeetCode] Container With Most Water 简要分析

前言这题非要说贪心的话也算是吧,不过最主要的特征还是双指针。LC的题好像不少都是扔倆头尾指针然后遍历一遍完事儿的。这道题倒是“短板效应”的不错体现了。题目题目链接Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are d

2015-12-04 16:42:34 430

原创 [LeetCode] Two Sum水过

刷LeetCode的第一题,TwoSum,基本算是水过。题目:https://leetcode.com/problems/two-sum/Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum shou

2015-12-04 10:29:48 560

空空如也

空空如也

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

TA关注的人

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