![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
面试
文章平均质量分 66
kgblily205
这个作者很懒,什么都没留下…
展开
-
leetCode:Binary Tree Postorder Traversal,Binary Tree Preorder Traversal--JAVA version
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].原创 2014-09-06 02:22:04 · 453 阅读 · 0 评论 -
插入排序
#includeint * InsertSort(int *,int len);int main(){ int i; int a[]={10,8,4,3,9,6,2,7,1,5}; int *p; p=InsertSort(a,10); for(i=0;i<10;i++){ printf("%d ",*(p+i)); } return 0;}int * Insert原创 2014-08-26 16:12:04 · 334 阅读 · 0 评论 -
快速排序
#includeint QuickSort(int*,int,int);int partition(int*,int,int);int main(){ int i; int a[]={10,8,4,3,9,6,2,7,1,5}; int length=10; QuickSort(a,0,length-1); for(i=0;i<length;i++){ printf("%原创 2014-08-26 17:49:03 · 383 阅读 · 0 评论 -
leetCode:Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.原创 2014-09-10 16:34:43 · 476 阅读 · 0 评论 -
用小白鼠鉴别有毒药水问题
http://www.cnblogs.com/mingmingruyuedlut/archive/2011/10/14/2211237.html题设:有N瓶水,其中有一瓶水有剧毒,如果小白鼠喝了会在24小时的时候死亡。问:用多少只小白鼠能够检测出哪瓶水有剧毒?要求:用的小白鼠数量少并且用时要短,并给出合理的过程与结论。我的解题思路如下:这是一个二进制开关(0/1)问转载 2014-08-27 20:17:34 · 703 阅读 · 0 评论 -
反转链表
#include#includetypedef struct LNode{ int num; struct LNode * next;}LNode,*LinkList;LinkList linkreverse(LinkList );LinkList reverse(LinkList);int main(){ LinkList a,b,c,d,head; head=(Link转载 2014-08-28 16:28:31 · 402 阅读 · 0 评论 -
堆排序(算法导论)
#include#include#define OK 1int build_max_heap(int[],int);int main(){ int A[]={4,1,3,2,16,9,10,14,8,7}; int length=10; //build_max_heap(A,length); heap_sort(A,length); int i; for(i=0;i<lengt原创 2014-08-29 16:53:29 · 425 阅读 · 0 评论 -
先序、中序、后序遍历二叉树 算法
#include#include#define OK 1#define ERROR 0int max_min=0;typedef struct BiTNode{ int data; struct BiTNode * lchild; struct BiTNode * rchild;}BiTNode,*BiTree;int visit_output(BiTree T);int原创 2014-08-30 12:31:02 · 628 阅读 · 0 评论 -
C语言 图的深度 遍历
#include#include#include#define OK 1#define ERROR 0#define GVexnum 8int visited[GVexnum];//define as the global array//---------define the graphic--------------typedef struct ArcNode{ int ad原创 2014-08-31 15:20:46 · 696 阅读 · 0 评论 -
图的 广度优先 搜索
#include#include#include#define OK 1#define ERROR 0//--------define the queue----------------typedef struct QNode{ int data; struct QNode *next;}QNode,*QueuePtr;typedef struct{ QueuePtr f原创 2014-08-31 13:21:01 · 462 阅读 · 0 评论 -
阿克曼函数
维基百科:阿克曼函数http://zh.wikipedia.org/wiki/%E9%98%BF%E5%85%8B%E6%9B%BC%E5%87%BD%E6%95%B8阿克曼函数是非原始递归函数的例子;它需要两个自然数作为输入值,输出一个自然数。它的输出值增长速度非常高,仅是(4,3)的输出已大得不能准确计算。1920年代后期,数学家大卫·希尔伯特的学生Gabriel转载 2014-09-25 11:51:57 · 8075 阅读 · 1 评论 -
leetCode:ZigZag Conversion
#include#includeusing namespace std;class Solution{public: int convert(string s,int nRows);};int Solution::convert(string s,int nRows){ int length=s.length(); int interval=2*nRows-原创 2014-09-25 16:06:28 · 434 阅读 · 0 评论 -
leetCode:Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length ofS is 1000, and there exists one unique longest palindromic substring#include#includeus转载 2014-09-25 13:15:13 · 488 阅读 · 0 评论 -
字符串的一些基本操作
#include#includechar *revstr(char *str,size_t);int strlength(const char *);int strcmpcompare(const char *,const char *);char* strconcat(const char *,const char *);int main(){// char string[]="P原创 2014-08-26 14:32:17 · 450 阅读 · 0 评论 -
leetCode: BInary Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.原创 2014-09-09 20:20:50 · 455 阅读 · 0 评论 -
一道阿里巴巴笔试题
http://blog.csdn.net/hehainan_86/article/details/11826905今天看了阿里的一道笔试题:如下函数,在32bit系统foo(2^31-3)的值是:Int foo(int x){Return x&-x;}A: 0 B: 1 C:2 D:4也没想那么多,觉得需要借助计算机编程才能得到答案!事实上呢,看看下转载 2014-08-26 21:07:58 · 830 阅读 · 0 评论 -
leetcode题目:reverse words in a string
public class Solution { public static String reverserWords(String s){ String[] Array=s.split(" "); int len=Array.length;//length of array int low=0;int high=len-1;int i=0; while(i<len && low原创 2014-09-05 16:13:52 · 471 阅读 · 0 评论 -
leetcode generate parentheses
pu newstr+=")"; recursive(left, right+1,n, newstr, list); } } public static void main(String[] args){ ArrayList list=new ArrayList(); list=generatePa转载 2014-09-05 18:48:36 · 381 阅读 · 0 评论 -
leetCode: same tree
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-06 23:27:51 · 416 阅读 · 0 评论 -
n节点组成二叉树的个数
可以分析,当n=1时,只有1个根节点,则只能组成1种形态的二叉树,令n个节点可组成的二叉树数量表示为h(n),则h(1)=1; h(0)=0; 当n=2时,1个根节点固定,还有2-1个节点。这一个节点可以分成(1,0),(0,1)两组。即左边放1个,右边放0个;或者左边放0个,右边放1个。即:h(2)=h(0)*h(1)+h(1)*h(0)=2,则能组成2种形态的二叉转载 2014-09-07 00:17:24 · 1308 阅读 · 0 评论 -
leetCode: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 sum原创 2014-09-08 00:43:25 · 498 阅读 · 0 评论 -
leetCode:Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra原创 2014-09-06 16:14:50 · 422 阅读 · 0 评论 -
leetCode: binary tree sum
题目是:有一颗二叉树,每个节点都是0~9转载 2014-09-06 18:28:34 · 386 阅读 · 0 评论 -
leetCode:Pascal's Triangle II
#include#includeusing namespace std;class Solution{public: vector generate(int numRows){ vector > temp; if(numRows<=0) return temp[numRows]; for(int i=0;i<numRows+1;i原创 2014-09-07 21:11:45 · 451 阅读 · 0 评论 -
leetCode:Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]转载 2014-09-07 17:33:27 · 531 阅读 · 0 评论 -
leetCode:Reverse Integer
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-08 04:13:56 · 430 阅读 · 0 评论 -
leetCode:Linked List Cycle II
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.For example,X X X XX O O XX X原创 2014-09-07 11:35:34 · 488 阅读 · 0 评论 -
leetCode:Minimum Depth of Binary Tree
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.原创 2014-09-08 02:17:03 · 489 阅读 · 0 评论 -
leetCode:Palindrome Number
Palindrome NumberTotal Accepted: 22288 Total Submissions: 76684 Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could nega原创 2014-09-25 22:18:54 · 425 阅读 · 0 评论