自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(49)
  • 资源 (1)
  • 收藏
  • 关注

原创 (c++)——内联函数

首先,内联函数通常是较小的函数,但是为什么要提出使用它呢?我们的代码通常需要一些共同的操作,但是,当需要进行对此修改呢,这时就需要没一个修改,可以想到将此操作定义成函数,但是新的问题又出现了,函数的话必须进行函数调用,调用的过程是保存以前的寄存器状态,并在调用结束后复原。可样可能进行操作的时间还没有函数调用的时间。得不偿失。因此我么将此类函数声明为内联函数。它是在调用时将该函数

2016-07-02 14:24:04 261

原创 Binary Tree Right Side View

问题Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree,

2015-11-20 16:33:12 336

原创 Binary Tree Maximum Path Sum

问题Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. Th

2015-11-20 16:31:17 309

原创 Kth Smallest Element in a BST

问题Given a binary search tree, write a function kthSmallest to find thekth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.解答class Solution1 {pu

2015-11-20 16:29:45 314

原创 Path Sum

问题Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and

2015-11-20 16:27:51 284

原创 Populating Next Right Pointers in Each Node II

问题Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant

2015-11-20 16:26:21 253

原创 Populating Next Right Pointers in Each Node

问题Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. If

2015-11-20 16:05:32 268

原创 Symmetric Tree

问题Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the follo

2015-11-20 16:03:29 300

原创 Unique Binary Search Trees II

问题Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1

2015-11-20 15:56:42 246

原创 Validate Binary Search Tree

问题Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.

2015-11-20 15:55:02 243

原创 Path Sum II

问题Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \

2015-11-20 15:52:06 303

原创 Lowest Common Ancestor of a Binary Tree

问题Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two no

2015-11-20 15:49:40 261

原创 Binary Tree Maximum Path Sum

问题Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. Th

2015-11-20 15:47:46 302

原创 Perfect Squares

1.问题描述Given a positive integer n, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because12 = 4 + 4 + 4; giv

2015-11-20 15:45:46 250

原创 Sort List

1.问题描述Sort a linked list in O(n log n) time using constant space complexity.链表排序。2.解答/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; *

2015-11-20 15:42:47 251

原创 Factorial Trailing Zeroes

1.问题描述Given an integer n, return the number of trailing zeroes in n!.阶乘的连续后缀零个数。2.解答int trailingZeroes(int n) { int sum=0; while(n) { while(n%5==0)

2015-11-20 15:40:32 252

原创 Palindrome Partitioning

1.问题描述Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [

2015-11-20 15:37:35 258

原创 C语言笔试面试总结(网上搜集)

1.关键字static的作用是什么?有三个明显的作用:1)在函数体内,一个被声明为静态的变量在这个函数被调用过程中维持其值不变2)在模块内(但在函数体外),静态的变量可以被模块内所有函数访问,但不能被模块外其他函数访问3)在模块内,一个被声明为静态的函数只能被这一模块内的其他函数调用,也就是,这个函数被限制在声明它的模块的本地范围内使用2. 如何保证头文件的内容只被包含一次,请

2015-11-19 15:55:42 2060

原创 预编译命令

预编译:在真正编译之前设置一些变量,环境设置。主要的命令有#define——宏定义:文本替换,不能提供变量类型检查,还有需要主要宏定义函数时,结合顺序有时候发生变化。#if #elif #else #endif可以实现代码的分块执行。实现分块调试。#include#include#define num 1 int main() {#if num==1

2015-11-09 11:04:16 412

原创 C标准库(1)

提供宏assert的定义。还需要引用宏NDEBUG。如果定了DNEBUG则不执行assert语句。void assert(int expression);如果断言错误,执行abort函数。

2015-11-08 14:01:58 275

原创 Word 编辑技巧平时总结

画表格:插入——表格—(表格类型可以自由组合)公式与本行字不对齐问题:选中公式——在开始中选择段落——中文版式——文本对齐方式。在编辑文本时,需要查看显示/隐藏编辑标签。表格编辑时,是作为整个一体的,编辑时需要选择——页面布局——组合。开始中字体中有上下脚标。插入图片时候:需要选择图片位置: 双击图片,——位置。嵌入环绕等。

2015-11-06 10:34:16 235

原创 linux——创建用户及所属组总结

创建用户创建用户时可以使用adduser或者useradd都可以,创建后可以使用passwd设置登录密码。需要注意的是:在ubuntu下发现设置了-d主目录和家目录的情况下,并没有创建。这是必须增加-m选项即可。如果在创建帐号时发现,一些选项设置错误时,可以使用usermod进行对帐号更改。创建组可以使用groupadd命令来增加一个新的组。一个用户可以属于多个组。把一

2015-10-08 14:03:06 3413

原创 Perfect Squares

一道编程题:描述:Given a positive integer n, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because12 = 4 + 4 + 4;

2015-09-13 21:33:53 325

原创 linux下创建线程

创建线程函数总结:包含头文件信息 pthread.h线程创建:int pthread_create(pthread_t *thread,pthread_attr_t *attr,void*(*start_routine)(void *),void *arg);pthread_t *thread 使用该指针进行引用创建的线程pthread_attr_t *attr 线程属

2015-09-08 13:56:33 362

原创 linux——shell流程控制

每种语言都有自己的流程控制,判断语句、循环语句。shell和他们一样,if判断、for、while循环等。if判断:         if 判断条件         then                commands         else                commands          fi  判断条件:主要判断以下三种情况。test 和

2015-09-02 22:14:55 928

原创 linux——函数库管理

函数库       程序开发中,将一些具有一定功能、且经常被调用的函数编译成函数库。函数库可以使得程序的开发简单、方便。函数库分为静态和动态。之间也存在一定的区别。静态函数库       这类函数库以扩展名.a结束。这类函数库通常为libxxx.a类型。他们是在编译的时候直接整合到执行程序当中,所以在程序中只要用到这类库的时候,都会存在一份库函数。这类函数库的最大优点是当编译成可执

2015-09-02 19:07:03 339

原创 linux——工作管理(job control)

在自己的bash中,如果有多个工作需要处理,就需要进行job control,把其中一些工作可以放进背景中。直接将指令放到背景中执行 :&将目前的工作放到背景中暂停:ctrl+z观察目前背景工作状态:jobs [-l (job number,PID) -r (run) -s (stop)]将背景工作拿到前景来处理:fg %jobnumber让工作在背景下的状态变成运行状态:bg %jobn

2015-08-31 10:17:52 1268

原创 linux shell——命令之乐

用cat进行拼接它通常用于读取、显示、或者拼接文件内容。cat(concatenate拼接)一般写法:cat file1 file2...末尾拼接显示到stdin。若要输出到文件时需要重定向。也可以将stdin内容和文件拼接 echo "text from stdin" | cat - file.txt      -作为stdin的文件名。cat常用选项:cat -s file

2015-08-28 10:41:22 413

原创 linux shell——小试牛刀

《linux shell 脚本攻略》笔记。小试牛刀——知识总结脚本运行 脚本文件提供x权限 chmod a+x filename, ./filenamesh filename ,/bin/bash filename终端环境:~/.bashrc ~/.bash_history终端输出和读取echo 显示“string" ——在字符串中的特殊符号会进行替换 $var

2015-08-27 16:43:24 311

原创 常用正则表达式字符

常用正则表达式,日常查看。摘图鸟哥私房菜。扩展RE字符

2015-08-25 13:56:35 262

转载 Linux SSH远程文件/目录传输命令scp

Linux SSH远程文件/目录传输命令scp相信各位VPSer在使用VPS时会 经常在不同VPS间互相备份数据或者转移数据,大部分情况下VPS上都已经安装了Nginx或者类似的web server,直接将要传输的文件放到web server的目录,然后在目标机器上执行:wget http://www.vpser.net/testfile.zip 就行了。当VPS上没有安装web server

2015-08-24 20:34:22 554

转载 ssh常用用法小结

ssh常用用法小结ssh常用用法小结1、连接到远程主机:命令格式 :ssh name@remoteserver 或者ssh remoteserver -l name说明:以上两种方式都可以远程登录到远程主机,server代表远程主机,name为登录远程主机的用户名。2、连接到远程主机指定的端口:命令格式:ssh name@remoteserver -

2015-08-24 20:25:55 270

原创 (c++)——内联函数

首先,内联函数通常是较小的函数,但是为什么要提出使用它呢?我们的代码通常需要一些共同的操作,但是,当需要进行对此修改呢,这时就需要没一个修改,可以想到将此操作定义成函数,但是新的问题又出现了,函数的话必须进行函数调用,调用的过程是保存以前的寄存器状态,并在调用结束后复原。可样可能进行操作的时间还没有函数调用的时间。得不偿失。因此我么将此类函数声明为内联函数。它是在调用时将该函数

2015-07-20 19:45:24 278

原创 使用gdb调试程序

gdb是一个功能很强大的调试器,它是一个自由软件,能够使用在很多的UNIX平台上,它同时也是linux系统默认的调试器。一般来说,GDB主要帮忙你完成下面四个方面的功能:    1、启动你的程序,可以按照你的自定义的要求随心所欲的运行程序。    2、可让被调试的程序在你所指定的调置的断点处停住。(断点可以是条件表达式)    3、当程序被停住时,可以检查此时你的程序中所发生的

2015-07-10 10:54:24 396

原创 回溯法——列举多维向量

1.回溯法概述   对于单维或者低维向量进行搜索时,可以非常简单的使用循环来遍历。但是随着维度的增加要怎么进行遍历呢?没错,使用回溯法可以对多维向量进行exhaustive searching。   它的通用编程模式: backtrack( [v1,...,vn] ) { if ( [v1,...,vn] is well-generated )

2015-07-06 09:53:50 479

原创 和为固定值的所有序列

1.问题描述   给定一个随意的向量,找到和为固定值的所有不同的序列。   例如:向量10,1,2,7,6,1,5 和为8   应该得到序列:   [1,7]   [1,2,5]   [2,6]   [1,1,6]   要求:序列中所有值都是整数,输出元素是从小到大排序的。输出的集合不能有重复的;2.解法   解析:1:因为要求输出是排序的,那么可以首先对序

2015-07-01 12:51:42 492

转载 王垠:完全用 GNU/Linux 工作

完全用 GNU/Linux 工作理解 GNU/Linux注:本文是清华“牛仔”王垠的“成名作”,在网上引起很大的争议。对他崇拜地五体投地者有,对他嗤之以鼻者也有,总之成了一年多以前Linux 爱好者的圈子里的一个很有意思的现象。之后他对这篇文章进行了很大的修改,已经没有了原来那种意气风发。现存的版本如白开水一般无味,请参 见:http://learn.tsinghua.edu.cn/hom

2015-06-29 20:17:55 790

原创 KMP算法解析

1.算法解决问题描述       字符串匹配问题,即在长的字符串序列中去匹配短的字符串。2.算法解析       简单的字符串匹配是通过对匹配字符串平移一位,进行逐个比较。这样的话算法复杂度达到o(n*m).KMP算法是首先得出匹配字符串的特征,这样当两个不匹配时,不用只是平移一位了。极大的减少复杂度。它可以达到o(n+m)。KMP算法主要的是求覆盖函数(overlay_f

2015-06-29 18:42:47 512

转载 最长上升子序列LIS算法实现

转自:点击打开链接最长上升子序列LIS算法实现  最长上升子序列问题是各类信息学竞赛中的常见题型,也常常用来做介绍动态规划算法的引例,笔者接下来将会对POJ上出现过的这类题目做一个总结,并介绍解决LIS问题的两个常用算法(n^2)和(nlogn).问题描述:给出一个序列a1,a2,a3,a4,a5,a6,a7....an,求它的一个子序列(设为s1,s2,...sn),使得这个子序列满

2015-06-28 16:11:37 342

原创 二分查找

对排序序列进行查找,可以进行二分查找,时间复杂度为O(log(n)). 原理很简单,但是能正确无误的写出其代码,也并不容易。主要需要注意的是:循环条件的判断和右端标记的下次迭代。 当left<=right; right=middle-1; 当leftint search(int array[], int n, int v){ int left, right, middle;

2015-06-27 14:21:54 317

精通数字图像处理算法及实现源码

包含了图像处理各种常用算法,还对图像处理各种知识点的详细介绍。

2013-09-22

空空如也

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

TA关注的人

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