- 博客(29)
- 资源 (4)
- 收藏
- 关注
原创 Unique Binary Search Trees (leetcode)
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \
2014-10-29 21:40:35
468
转载 数据模型 (LP32 ILP32 LP64 LLP64 ILP64 )
32位环境涉及"ILP32"数据模型,是因为C数据类型为32位的int、long、指针。而64位环境使用不同的数据模型,此时的long和指针已为64位,故称作"LP64"数据模型。现今所有64位的类Unix平台均使用LP64数据模型,而64位Windows使用LLP64数据模型,除了指针是64位,其他基本类型都没有变。 TYPE LP32 ILP32 L
2014-10-29 12:29:11
926
原创 Climbing Stairs (leetcode)
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
2014-10-29 10:52:45
450
转载 C++11 修复了双重检查锁定问题
转自: 导读:本文是关于C++11标准中修复了双重检查锁定模式的消息,同时作者阐述了实现双重检查锁定模式的诸多方法,并逐一进行了分析,作者还提供了一个在早期编译器上实现双重检查锁定模式的库。双重检查锁定模式(DCLP)在无锁编程(lock-free programming)中经常被讨论,直到2004年,JAVA才提供了可靠的双重检查锁定实现。而在C++11之前,C++没有提
2014-10-13 12:46:41
726
原创 Two Sum (leetcode)
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where
2014-10-10 17:33:56
398
原创 Validate Binary Search Tree (leetcode)
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.The
2014-09-26 23:07:21
433
转载 A program to check if a binary tree is BST or not
A binary search tree (BST) is a node based binary tree data structure which has the following properties.• The left subtree of a node contains only nodes with keys less than the node’s key.• The r
2014-09-25 22:52:44
665
原创 Minimum Depth of Binary Tree (leetcode)
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.https://oj.leetcode.com/problems/m
2014-09-23 23:13:33
578
原创 Convert Sorted Array to Binary Search Tree (leetcode)
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
2014-09-23 21:49:15
446
原创 Sort List (leetcode)
Sort a linked list in O(n log n) time using constant space complexity.
2014-09-21 14:33:34
344
原创 Path Sum (leetcode)
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 sum
2014-09-21 13:26:28
417
原创 Copy List with Random Pointer (leetcode)
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.
2014-09-20 22:09:44
408
原创 Reorder List (leetcode)
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to {1,4
2014-09-20 22:08:35
357
原创 Linked List Cycle II (leetcode)
Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?
2014-09-20 22:01:27
362
原创 Unique Binary Search Trees (leetcode)
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \
2014-09-20 21:58:09
370
原创 Best Time to Buy and Sell Stock II (leetcode)
Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one
2014-09-20 21:57:55
363
原创 Reverse Integer (leetcode)
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before coding.
2014-09-20 21:53:52
378
原创 Same Tree (leetcode)
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
2014-09-20 21:49:41
369
原创 LRU Cache (leetcode)
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:get and set.get(key) - Get the value (will always be positive) of the key if t
2014-09-20 21:45:17
526
转载 Singleton之C++部分一
采用静态或者全局变量的实现方案由于C++不能保证静态或者全局对象的构造函数的调用顺序以及析构顺序。所以如果程序中有多个用此方法实现的Singleton类,它们之间又有某种构造依赖关系和析构依赖关系,就会造成灾难性的后果。所以,只有当肯定不会有构造和析构依赖关系的情况下,这种实现才是合适的。>优点实现简单,多线程下安全>缺点如果有多个Singleton
2013-09-03 22:50:20
601
原创 单向链表排序-归并排序
链表排序中使用归并排序:归并排序不仅保持了它的 O( nlog(n) ) 的时间复杂度,而且它在数组排序中广受诟病的空间复杂度,在链表排序中从 O(n) 降低到 O( log(n) )。 对于单向链表的二路归并排序,首先是要找到链表的中间节点,将链表等分。我们可以使用快慢指针的方式找到链表的中间节点,即一个指针以一个步长移动,另一个指针使用两个步长移动,当快指针到结尾位置时,慢指针正好在中
2013-04-21 23:31:05
1428
原创 KMP 算法
//参考算法导论 #include #include // 前缀函数int *compute_prefix_function(const char *needle){ int len = strlen(needle); int *c = new int[len]; memset(c, 0, len * sizeof(int));
2012-10-07 23:36:34
306
转载 Change Journals
An automatic backup application is one example of a program that must check for changes to the state of a volume to perform its task. The brute force method of checking for changes in directories or f
2011-10-26 20:25:49
517
转载 sysconf、pathconf和fpathconf函数
1.限制Unix系统实现定义了很多幻数和常量,这些在不同程度上依从POSIX,也遵从POSIX.1标准。这就有助于软件的可移植性。以下两种类型的限制是必须的:1) 编译时限制(例如,短整型的最大值是什么?)2) 运行时限制(例如,文件名可以有多少个字符?)编译
2011-09-16 00:18:21
469
转载 C++查看内存泄露的方法(转载)
转载自:http://www.examda.com/ncre2/cpp/jiqiao/20100624/082137361.html<br /><br />一. 在 MFC 中检测内存泄漏<br /> 假如是用MFC的程序的话,很简单。默认的就有内存泄露检测的功能。<br /> 我们用VS2005生成了一个MFC的对话框的程序,发现他可以自动的检测内存泄露.不用我们做任何特殊的操作. 仔细观察,发现在每个CPP文件中,都有下面的代码:<br /> #ifdef _DEBUG<br /> #defin
2011-05-05 00:19:00
1443
原创 自己编写 shell 命令 实现安全的删除文件
<br />#!/bin/bash<br /><br />## 建立文件回收站机制<br />## 将需要删除的文件移动到 ~/.trash 中<br /><br />#如果 ~/.trash 文件不存在,就创建<br />if [ ! -d ~/.trash ];<br />then<br /> mkdir ~/.trash<br />fi<br /><br /><br />if [ $# -eq 0 ];<br />then<br /> #提示dele
2011-04-30 15:22:00
1163
转载 在 CpropertySheet 添加 最大化框 最小化框
<br />新建一个基于CPropertySheet的类, <br /> <br /> 在OnInitDialog中加入 (注意:OnInitDialog 是 CPropertySheet类的虚函数 )<br /> <br /> CMenu* pSysMenu = GetSystemMenu(FALSE); <br /> if (pSysMenu != NULL) <br /> { <br /> //..
2011-04-26 20:39:00
1302
原创 快速排序
<br />#include <iostream><br />using namespace std;<br /><br />//交换数据<br />template <typename T><br />void swapValue( T & a , T & b)<br />{<br /> T temp = a;<br /> a = b;<br /> b = temp;<br />}<br /><br />//快速排序,只执行一趟 (方法一)<br
2011-04-26 12:39:00
288
原创 大数据量,海量数据 处理方法总结
<br /><br />大数据量,海量数据处理方法总结(转)<br /><br /><br />大数据量的问题是很多面试笔试中经常出现的问题,比如baidu google 腾讯这样的一些涉及到海量数据的公司经常会问到。<br /><br />下面的方法是我对海量数据的处理方法进行了一个一般性的总结,当然这些方法可能并不能完全覆盖所有的问题,但是这样的一些方法也基本可以处理绝大多数遇到的问题。下面的一些问题基本直接来源于公司的面试笔试题目,方法不一定最优,如果你有更好的处理方法,欢迎与我讨论。<br /><b
2011-04-25 15:50:00
471
Python网络数据采集
2017-02-17
Distinctive Image Features from Scale-Invariant Keypoints
2011-05-03
最易理解的SVM入门教程
2011-05-03
PCA _SIFT A More Distinctive Representation for Local Image Descriptors
2011-04-27
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人