自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

灯火阑珊处

相爱没有那么容易,每个人有ta的脾气

  • 博客(61)
  • 问答 (1)
  • 收藏
  • 关注

原创 LeetCode OJ 之 Binary Tree Zigzag Level Order Traversal (二叉树的曲线层次遍历)

题目:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).给定一棵二叉树,返回曲线层次遍历的结

2014-12-25 18:28:18 619

原创 UNIX环境高级编程-第10章- 信号 - 二

10.15 sigsetjmp和siglongjmp 函数7.10节介绍了两个关于用于非局部跳转的 setjmp 和 longjmp 函数,在信号处理程序中经常调用 longjmp 函数以返回到程序的主循环中,而不是从该处理程序返回。但是调用 longjmp 有一个问题,当捕捉到一个信号时,进入信号捕捉函数,此时当前信号被自动加到进程的信号屏蔽字中。这阻止了后来产生的这种信号中断该信号处理程序

2014-12-25 16:27:48 542

原创 LeetCode OJ 之 Construct Binary Tree from Preorder and Inorder Traversal (由二叉树的前序和中序序列构造二叉树)

题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.给定一棵树的前序和中序遍历结果,构造这棵二叉树,假设二叉树不存在重复的元素。思路:思路类

2014-12-25 10:58:08 498

原创 LeetCode OJ 之 Construct Binary Tree from Inorder and Postorder Traversal (由二叉树的中序和后序序列构造二叉树)

题目:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.给定一棵树的前序和后序遍历结果,构造这棵二叉树,假设二叉树不存在重复的元素。思路:

2014-12-25 08:59:42 514

原创 UNIX环境高级编程-第10章- 信号 - 一

10.2 信号基本概念          信号本质是在软件层次上对中断机制的一种模拟,即软件中断;在原理上,一个进程收到一个信号或处理器收到一个中断请求可以说是一样的。信号是异步的,一个进程不必通过任何操作来等待信号的到达,进程也不知道信号到底什么时候到达。信号是进程间通信机制中唯一的异步通信机制,可以看作是异步通知,通知接收信号的进程有哪些事情发生了。        信号事件的发生有

2014-12-24 16:49:21 486

原创 LeetCode OJ 之 Generate Parentheses (产生括号)

题目:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(()

2014-12-24 08:23:42 445

原创 UNIX环境高级编程-第9章- 进程关系

9.4 进程组 在UNIX 系统中,每个进程除了自己的进程 ID之外,还属于一个进程组。进程组是一个进程或多个进程的集合,进程组本身也有属于自己的进程组ID,进程组属于一个会话,fork()并不改变进程组ID。进程组组长:        进程ID与进程组ID相等的进程。组长可以改变子进程的进程组ID,使其转移到另一进程组。组长进程可以在所在的进程组创建进程,然后终止,从进程组创建开始到

2014-12-23 17:11:47 721

原创 LeetCode OJ 之 Gas Station (加油站)

题目:There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from statio

2014-12-23 10:27:27 728

原创 LeetCode OJ 之 Combination Sum II (“连接”和 - 二)

题目:Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the

2014-12-23 08:45:18 390

原创 LeetCode OJ 之 Combination Sum (“连接”和)

题目:Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlim

2014-12-22 22:29:48 434

原创 UNIX环境高级编程-第8章- 进程控制 - 二

8.10 exec函数exec 替换进程映像        在进程的创建上 UNIX 采用了一个独特的方法,它将进程创建与加载一个新进程映象分离,这样可以方便对两种操作进行管理。当创建了一个进程之后,通常可以用 exec 系列的函数将子进程替换成新的进程映象。当然,exec 系列的函数也可以将当前进程替换掉。exec 序列函数        fork 函数创建一个子进程时,几乎复制

2014-12-22 16:18:03 514

原创 LeetCode OJ 之 Longest Substring Without Repeating Characters (无重复的最长子串)

题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is

2014-12-22 10:05:01 546

原创 LeetCode OJ 之 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

2014-12-22 09:58:27 615

原创 LeetCode OJ 之 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

2014-12-22 08:47:54 1914

原创 UNIX环境高级编程-第8章- 进程控制 - 一

8.3 fork 函数在 UNIX 系统中,一个现有进程可以调用 fork 函数创建一个新进程。调用 fork 函数的进程称为父进程,由 fork 创建的新进程被称为子进程(child process)。fork函数被调用一次但返回两次,两次返回的唯一区别是子进程中返回0值而父进程中返回子进程ID。首先看下fork函数的原型;/* 创建进程 */ /* fork 函数 */

2014-12-21 17:11:36 629

原创 LeetCode OJ 之 Palindrome Partitioning (字符串的回文分割)

题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.给定一个字符串s,把它分割成每个子串都是回文形式,返回所有的分割可能。For ex

2014-12-20 20:28:08 496

原创 UNIX环境高级编程-第7章- 进程环境

7.2 main 函数         C程序总是从 main 函数开始执行。main 函数的原型是         int main ( int argc , char * argv[] );其中,argc 是命令行参数的数目,argv 是指向参数的各个指针所构成的数组。当内核执行C程序时(使用一个exec函数执行),在调用mian函数前先调用一个特殊的启动例程。可执行程序文

2014-12-20 16:05:44 631

原创 UNIX环境高级编程-第6章- 系统数据文件和信息

6.2 口令文件口令文件的结构/* The passwd structure. */ struct passwd { char *pw_name; /* Username. */ char *pw_passwd; /* Password. */ uid_t pw_uid; /* User ID. *

2014-12-19 17:18:28 497

原创 UNIX环境高级编程-第5章- 标准 I/O 库

5.2 流和 FILE 对象 前面介绍的《文件I/O》都是针对文件描述符进行操作的,并且是非缓冲区方式的。本节记录的标准I/O的操作是在流进行的,当用标准I/O打开或创建一个文件时,已使一个流与一个文件相关联。       标准I/O文件的流可用于单字节或多字节(宽)字符集。流的定向决定所读、写的字符是单字节还是多字节。流最初被创建时,并没有定向,若在未定向的流上使用一个多字节I/O函数,

2014-12-19 15:23:49 502

原创 UNIX环境高级编程-第4章- 文件和目录 - 三

前言       在Linux系统中利用ln指令产生链接,Linux链接分两种,一种被称为硬链接(Hard Link),另一种被称为符号链接(Symbolic Link)。默认情况下,ln命令产生硬链接。硬链接       硬链接是一种通过文件系统的inode链接产生,硬链接可以认为是一个指针,指向文件inode的指针,系统并不为它重新分配inode。所以存在多个文件指向同一个

2014-12-18 15:58:48 439

原创 LeetCode OJ 之 Search in Rotated Sorted Array (有序数组翻转后的查找)

题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the ar

2014-12-18 10:37:29 1088

原创 LeetCode OJ 之 Binary Tree Postorder Traversal (二叉树的后序遍历)

题目:Given a binary tree, return the postorder traversal of its nodes' values.给定一个二叉树,返回后序遍历的结果。For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3

2014-12-18 09:41:05 575

原创 LeetCode OJ 之 Binary Tree Preorder Traversal (二叉树的前序遍历)

题目:Given a binary tree, return the preorder traversal of its nodes' values.给定一个二叉树,返回前序遍历的结果。For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,

2014-12-18 08:37:27 589

原创 LeetCode OJ 之 Find Peak Element (查找极大元素)

A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in

2014-12-17 22:43:14 505

原创 Linux中硬链接和软链接的区别和联系

硬链接与软链接是 Linux 文件系统中的一个重要概念,其涉及文件系统中的索引节点 (index node 又称 inode),而索引节点对象是 Linux 虚拟文件系统 (VFS) 的四个基本概念之一。通过剖析硬链接与软链接的联系与区别,我们可更好的了解 Linux 中 VFS 这一通用文件模型。并让 Linux 普通用户和系统管理员正确使用硬链接与软链接,帮助文件系统开发者获取 inode

2014-12-17 16:32:04 820

原创 UNIX环境高级编程-第4章- 文件和目录 - 二

4.8 umask函数当创建新文件是可以通过umask函数指定文件的访问权限。以下是文件权限值对应的数字:读R——数字4;写W——数字2;执行X——数字1; /************************** * 函数功能:为进程设置文件模式创建屏蔽字,并返回以前的值; * 函数原型: * * mode_t umask (mode_t cmask);

2014-12-17 16:31:20 588

原创 LeetCode OJ 之 Surrounded Regions (环域)

题目:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.给定一个包含 'x' 和 'o' 的二维板,

2014-12-17 12:36:11 419

原创 LeetCode OJ 之 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->

2014-12-17 10:30:26 476

原创 LeetCode OJ 之 Binary Tree Inorder Traversal (二叉树的中序遍历)

题目:Given a binary tree, return the inorder traversal of its nodes' values.给定一个二叉树,返回中序遍历后结点的值。For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1

2014-12-17 09:32:25 441

原创 关于C++中string类的查找函数的说明

string类的查找函数:int find(char c, int pos = 0) const;//从pos开始查找字符c在当前字符串的位置int find(const char *s, int pos = 0) const;//从pos开始查找字符串s在当前串中的位置int find(const char *s, int pos, int n) const;//从pos开始查找

2014-12-17 08:39:29 735

原创 LeetCode OJ 之 Compare Version Numbers (比较版本数)

题目:Compare two version numbers version1 and version 2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.比较版本1和版本2,如果版本1 > 版本2,返回1,如果版本1 You may assume

2014-12-16 22:22:59 967

原创 UNIX环境高级编程-第4章- 文件和目录 - 一

4.2 stat,lstat 和fstat函数/*********************** * 函数功能: 描述文件属性 * stat函数返回与pathname命名文件的相关信息结构; * fstat函数获取已在描述符filedes上打开的文件信息; * lstat函数获取符号连接的相关信息; * * 返回值:若成功则返回0,若出错则返回-1; * 函数原型:

2014-12-16 17:30:47 519

原创 UNIX环境高级编程-第3章- 文件I/O

3.1 引言        文件I/O可分为两类:第一类是非缓冲式的文件操作;该类型一般由系统调用,主要函数有open,write,read,lseek,close;第二类是缓冲式文件操作;该类型由标准输入输出提供操作;本文记录的是第一类文件I/O。3.2 文件描述符       内核通过文件描述符打开的文件,它是一个非负整数。通常,文件描述符0对应标准输入;文件描述符1对应标准输出;

2014-12-16 16:04:52 561

原创 UNIX环境高级编程-第0章- 关于apue.h和源码编译问题

《unix高级环境编程》这本书的源码下载连接http://www.apuebook.com/,这里有几个版本,根据需要下载。       为了能够方便学习,在你的编译环境能够使用apue.h这个头文件(这个头文件是作者自行编写的),所以我们必须要编译源码,使我们能够使用该头文件。编译的过程中会报错,这里列出我编译过程过解决错误的过程。       在进行make编译之前,准备工作的工作

2014-12-15 17:46:35 514

原创 LeetCode OJ 之 Flatten Binary Tree to Linked List (把二叉树转换成链表)

题目:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like:

2014-12-15 12:40:09 530

原创 LeetCode OJ 之 Convert Sorted List to Binary Search Tree(把有序链表转化为二叉搜索树)

题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.给定一个排好序(升序)的单链表,把它转化为一个平衡二叉搜索树。思路:请先参看”把有序数组转化为二叉搜索树“:http://blog.csdn.net/u01

2014-12-15 10:29:25 465

原创 LeetCode OJ 之 Convert Sorted Array to Binary Search Tree(把有序数组转化为二叉搜索树)

题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.把一个已经排好序(升序)的数组,转化为一个平衡二叉搜索树。思路:本题需要先了解二叉搜索树(参看:http://blog.csdn.net/u012243115/article/de

2014-12-15 09:33:34 2471

原创 LeetCode OJ 之 Unique Paths II(不同路径 - 二)

题目:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively

2014-12-14 16:44:46 558

原创 LeetCode OJ 之 Unique Paths (不同路径)

题目:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to r

2014-12-14 15:26:03 573

原创 LeetCode OJ 之 Find Minimum in Rotated Sorted Array II(查找旋转有序数组中的最小值 - 二)

题目:Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at som

2014-12-14 12:28:10 522

空空如也

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

TA关注的人

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