自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 资源 (3)
  • 收藏
  • 关注

原创 [LeetCode] 在矩阵中查找字符串 Search a string in a matrix of chars

在矩阵中查找字符串 Search a string in a matrix of chars [Leetcode 124: 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 sequent

2014-11-30 06:27:11 1889

原创 [leetcode] 区间合并问题 Merge Interval

Given a collection of intervals, merge all overlapping intervals.类似问题1:区间覆盖问题相关问题2:Rectangle Area IIFor example, given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18].来源:leetcode思路:用...

2014-11-30 04:49:46 2882

翻译 把零移动到数组的一端 Move all zeroes to end of array

把零移动到数组的一端 Move all zeroes to end of array给定一个数组,把数组中所有的 0 移动到数组的右端,并保持其他非零元素的相对顺序。例如数组 {1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0}, 把 0 移动到右端,并保持相对顺序,结果是{1, 9, 8, 4, 2, 7, 6, 0, 0, 0, 0}.下面给出一个O(n)算法,空间复杂度

2014-11-29 10:57:21 639

原创 与二分搜索相关的几个问题

在先升后降的数组中查找  Search for an element in an array which has elements who’s values are first increasing 在旋转过的排序数组中查找 Search in a rotated array在排序数组中查找某个值出现的次数,元素可以重复出现。

2014-11-29 05:12:29 757

原创 三角形的数目 Count the number of possible triangles

给定一个无序数组,数组的每个元素代表了三角形可能的边长,找出所有可能的三角形的数目。注意:三角形的边长必须满足1)a+b>c; 2) b+c>a; 3) c+a > b.详见:http://www.geeksforgeeks.org/find-number-of-triangles-possible/代码如下:// Program to count number of triangle

2014-11-29 04:56:00 810

翻译 二叉树的高度 - 父节点序列 Find Height of Binary Tree by Parent Array

二叉树的高度 - 父节点序列 Find Height of Binary Tree by Parent ArrayA given array represents a tree in such a way that the array value gives the parent node of that particular index. The value of the root node

2014-11-29 03:47:24 636

转载 二叉树的串行化 Serialization of Binary Tree

二叉树的串行化 Serialization of Binary Tree转自:http://www.geeksforgeeks.org/serialize-deserialize-binary-tree/Serialization is to store tree in a file so that it can be later restored. The structure o

2014-11-28 07:21:09 2105

原创 找出整数的开方的floor -- 找出最近的平方数

Implement a fast integer square root function that takes in an integer and returns another integer that is the floor of the square root of the input.用二分搜索的思想,但是要注意本算法的递归搜索区间和二分搜索递归区间的区别。下面的正确性已经得到

2014-11-28 04:41:04 1201

原创 是否是二叉搜索树 check if it is binary search tree

是否是二叉搜索树 check if it is binary search treegeekforgeeks 给出了一个自顶向下的递归算法。自顶向下的思路:从根节点开始,向左右子树进发,逐步缩小范围。我给出一个自下朝上的递归算法。思路是:先判断左子树和右子树是不是BST。如果有一个不是,那么整个树就不是。如果两个子树都是,那么再看根节点值的大小。#include#includ

2014-11-27 11:26:18 700

原创 把两个链表加起来 add two numbers represented by two linked lists

把两个链表加起来 add two numbers represented by two linked lists如果从链表的头到尾是数字的低位到高位的方向,这道题非常好做,详见:http://www.geeksforgeeks.org/add-two-numbers-represented-by-linked-lists/。如果从链表的头到尾是数字的高位到低位的方向,那么可以先把这两个链表

2014-11-27 09:40:57 539

原创 [LeetCode] Next Permutation - Next bigger number with the same set of digits

下一个有着同样数字的数 Next bigger number with the same set of digits转自 http://stackoverflow.com/questions/9368205/given-a-number-find-the-next-higher-number-which-has-the-exact-same-set-of-digiI just

2014-11-27 07:31:25 1148

原创 最低公共祖先 lowest common ancestor

最低公共祖先 lowest common ancestorThe idea is to traverse the tree starting from root. If any of the given keys (n1 and n2) matches with root, then root is LCA (assuming that both keys are present). If

2014-11-27 06:38:28 642

原创 [LeetCode] 非递归中序遍历二叉树 non recursive inorder traversal

非递归中序遍历二叉树 non recursive inorder traversal 用两个 while 循环来做, 思路如下.1) Create an empty stack S.2) Initialize current node as root3) Push the current node to S and set current = current->left until

2014-11-27 00:30:00 1254

原创 在二叉搜索树里,寻找两个节点 Find a pair with given sum in a Balanced BST

在二叉搜索树里,寻找两个节点 Find a pair with given sum in a Balanced BST给定一个平衡二叉搜索树和一个目标和sum,写一个函数,如果有一对节点的和等于目标和, 返回true,否则返回false。预期时间复杂度是O(n),并只只能有O(logN)的额外的空间可以使用。修改二叉搜索树是不允许的。注意平衡BST的身高是O(LOGN)。一个更好的解决

2014-11-26 11:08:38 1051 1

转载 相同数目的0和1的子数组 Largest subarray with equal number of 0s and 1s

相同数目的0和1的子数组 Largest subarray with equal number of 0s and 1sFollowing is a solution that uses O(n) extra space and solves the problem in O(n) time complexity.Let input array be arr[] of size n and

2014-11-26 07:57:43 773

原创 [LeetCode] Merge Two Sorted Lists 归并两个排好序的单链表

归并两个排好序的单链表给定两个排过序的单链表,头指针分别是head1和head2,把他们合并成一个排序的单链表。思路:用递归的方法,把单链表head1中的节点,依次插入head2中。#include #include #include #define MAX 256using namespace std;struct Node{ int data;

2014-11-26 01:21:42 509

翻译 克隆一个有随机指针的二叉树 Clone a Binary Tree with Random Pointers

一个二叉树的节点有如下结构struct node { int key; struct node *left,*right,*random;}

2014-11-25 10:19:29 916

原创 有向图是否有环,无向图是否有环

有向图是否有环,无向图是否有环detect

2014-11-25 06:05:43 1630

原创 把二叉树的叶子节点连成一个二叉链表

把二叉树的叶子节点连成一个二叉链表

2014-11-25 05:14:15 1492

原创 子序列的最大几个值 maximum k elements in a subarray

子序列的最大几个值 maximum k elements in a subarray

2014-11-24 07:18:02 552

翻译 所有子序列的最大值 Maximum of all subarrays of size k

给定一个数组和一个整数k,

2014-11-24 05:34:34 719

翻译 复制双链表 Copy a linked list with next and arbit pointer

复制双链表 Copy a linked list with next and arbit pointer有一个双链表,这个shuanglian

2014-11-24 03:39:06 783

翻译 在排序数组中的出现次数 Count the number of occurrences in a sorted array

在排序数组中的出现次数 Count the number of occurrences in a sorted array给定一个排序数组

2014-11-24 02:36:26 624

原创 find the largest subset of consecutive integers 找到最大的连续整数子集

find the largest subset of consecutive integers 找到最大的连续整数子集

2014-11-23 14:12:19 755

转载 有序矩阵中查找第k小的元素 Kth smallest element in a row-wise and column-wise sorted 2D array

有序矩阵中查找第k小的元素 Kth smallest element in a row-wise and column-wise sorted 2D array

2014-11-23 04:31:01 2035

原创 最长的无重复字符的字符串 longest substring with no repeating characters

最长的无重复字符的字符串 longest substring with no repeating characters

2014-11-21 12:35:47 664

原创 求数组元素最大差值

一、问题描述:如果一个人在知道了股票每天的股价以后,对该股票进行投资,问什么时候买入和卖出(注意这里有先后顺序)能取得最大的收益。其数学模型就是,给定一个整数数组,a[1],a[2],...,a[n],每一个元素a[i]可以和它左边(a[i-1],a[i-2],...,a[0])元素做差,求这个数组中最大的差值。

2014-11-21 06:13:36 2529

原创 Set row and column to 1's

Given a matrix of size n x m filled with 0's and 1'se.g.:1 1 0 1 00 0 0 0 00 1 0 0 01 0 1 1 0if the matrix has 1 at (i,j), fill the column j and row i with 1'si.e., we get:

2014-11-21 04:40:35 734

原创 [LeetCode] Online Stock Span Problem

The Online Stock Span ProblemThe stock span problemis a financial problem where we have a series of n daily price quotes for a stock and we need to calculate span of stock’s price for all n days....

2014-11-18 06:11:33 1015

转载 Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted

Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted

2014-11-17 00:41:56 560

原创 拓扑排序-字典序

Amazon interview Experience | Set 130 (For SDET 1)http://www.geeksforgeeks.org/amazon-interview-experience-set-130-sdet-1/

2014-11-10 23:22:10 1404

转载 A Quiz About Integers in C

A Quiz About Integers in CYou scored 0 out of 20. Note: Sometimes scores are reported incorrectly -- sorry about that. I think it's a bug in the quiz plugin for WP that I'm using. I

2014-11-01 07:49:06 1033

Monte carlo模拟的Mathematica代码

本文件是用Mathematica代码编写的Monte carlo模拟。 包含均匀分布,指数分布,以及均匀分布在圆和球面上的点。

2010-04-10

网格搜索法--求公切线算法

网格搜索法--求公切线算法。Mathematica程序。

2009-07-08

北邮通信电子电路自测题

这是本人在北邮学习期间,搜集的通信电子电路自测题。老师给的。很有价值。

2009-07-08

空空如也

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

TA关注的人

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