
算法实现
文章平均质量分 78
lxf310
这个作者很懒,什么都没留下…
展开
-
LeetCode题目:Unique Binary Search Trees,一维动态规划
转载自:http://blog.unieagle.net/2012/11/01/leetcode%E9%A2%98%E7%9B%AE%EF%BC%9Aunique-binary-search-trees%EF%BC%8C%E4%B8%80%E7%BB%B4%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/用一维动态规划解。Sigma(左边的子树可能状态 * 右边转载 2014-03-11 11:56:32 · 611 阅读 · 0 评论 -
java面试题-HashMap原理
转载自:http://blog.chinaunix.net/uid-11775320-id-3143919.html1. HashMap概述 HashMap是基于哈希表的Map接口的非同步实现。此实现提供所有可选的映射操作,并允许使用null值和null键。此类不保证映射的顺序,特别是它不保证该顺序恒久不变。 2. HashMap的数据结构 在java编转载 2014-10-31 20:18:31 · 959 阅读 · 0 评论 -
动态规划:从新手到专家
转载自:http://hawstein.com/posts/dp-novice-to-advanced.html转载 2014-10-11 10:12:36 · 622 阅读 · 0 评论 -
【Killua笔试面试题整理】两个数组a[N],b[N],其中A[N]的各个元素值已知,现给b[i]赋值
转载自:http://blog.youkuaiyun.com/killua_hzl/article/details/7444864【题目描述】两个数组a[N],b[N],其中A[N]的各个元素值已知,现给b[i]赋值,b[i] = a[0]*a[1]*a[2]...*a[N-1]/a[i];要求:1.不准用除法运算2.除了循环计数值,a[N],b[N]外,不准再用其他任何变转载 2014-09-30 13:39:03 · 578 阅读 · 0 评论 -
DFS深度优先搜索案例:马戏团叠罗汉
转载自:http://blog.youkuaiyun.com/arhaiyun/article/details/119839132012创新工场校园招聘的一道编程算法题:马戏团里有个叠罗汉的表演,为了便于美观,下面的人身高和体重都要大于上面的人。现在知道n个演员的身高和体重,请问最多能叠多少层?设计思路:首先生成一个有向图map,用连接矩阵的方式来表示。map[i][j]==1表示转载 2014-09-30 13:38:16 · 724 阅读 · 0 评论 -
判断一个单链表是否有环及环的链接点
给定一个单链表,只给出头指针h:1、如何判断是否存在环?2、如何知道环的长度?3、如何找出环的连接点在哪里?4、带环链表的长度是多少? 解法:1、对于问题1,使用追赶的方法,设定两个指针slow、fast,从头指针开始,每次分别前进1步、2步。如存在环,则两者相遇;如不存在环,fast遇到NULL退出。2、对于问题2,记录下问题1的碰转载 2014-08-08 20:50:03 · 431 阅读 · 0 评论 -
C++ MD5加密实现
转载自:http://cooker.iteye.com/blog/969196//MD5.h #ifndef BZF_MD5_H#define BZF_MD5_H#include #include // a small class for calculating MD5 hashes of strings or byte arrays// it转载 2014-05-07 13:11:16 · 605 阅读 · 0 评论 -
不使用 +-×÷ 运算符来实现 加减乘除 四项运算
首先我们可以分析人们是如何做十进制的加法的,比如是如何得出5+17=22这个结果的。实际上,我们可以分成三步进行:第一步只做各位相加不进位,此时相加的结果是12(个位数5和7相加不要进位是2,十位数0和1相加结果是1);第二步做进位,5+7中有进位,进位的值是10;第三步把前面两个结果加起来,12+10的结果是22,刚好5+17=22。我们一直在想,求两数之和四则运算都不能用,那还能用什么?对转载 2014-03-31 11:31:51 · 638 阅读 · 0 评论 -
set intersection问题求解(python版)
Description:You are given two sorted list of numbers(ascending order). The lists themselves are comma delimited and the two lists are semicolon delimited. Print out the intersection of these two s原创 2013-01-01 19:04:33 · 2076 阅读 · 0 评论 -
Number Pairs(Python版)
Description:You are given a sorted array of positive integers and a number 'X'. Print out all pairs of numbers whose sum is equal to X. Print out only unique pairs and the pairs should be in ascen原创 2013-01-01 19:54:01 · 1228 阅读 · 0 评论 -
Flavius Josephus问题(Python版)
Description:Flavius Josephus was a famous Jewish historian of the first century, at the time of the destruction of the Second Temple. According to legend, during the Jewish-Roman war he was trap原创 2013-01-01 20:01:30 · 709 阅读 · 0 评论 -
Double Squares(Python版)
Description:A double-square number is an integer X which can be expressed as the sum of two perfect squares. For example, 10 is a double-square because 10 = 3^2 + 1^2. Your task in this problem原创 2013-01-01 19:49:22 · 689 阅读 · 0 评论 -
前缀表达式求值(Prefix expressions)
Description:You are given a prefix expression. Write a program to evaluate it.Input sample:The first argument will be an input file with one prefix expression per line. e.g.* + 2 3 4原创 2013-01-27 15:10:04 · 2325 阅读 · 1 评论 -
Self Describing Numbers自描述数字问题(Python版)
Description:A number is a self-describing number when (assuming digit positions are labeled 0 to N-1), the digit in each position is equal to the number of times that that digit appears in the num原创 2013-01-01 19:17:33 · 1179 阅读 · 0 评论 -
Lowest Common Ancestor(Python版)
Description:Write a program to determine the lowest common ancestor of two nodes in a binary search tree. You may hardcode the following binary search tree in your program: 30 | ___原创 2013-01-01 19:37:23 · 970 阅读 · 0 评论 -
字符串全排序问题(String Permutations)
Description:Write a program to print out all the permutations of a string in alphabetical order.Input sample:The first argument will be a text file containing an input string, one per line原创 2013-01-27 16:27:31 · 618 阅读 · 0 评论 -
Longest Lines(Python版)
Description:Write a program to read a multiple line text file and write the 'N' longest lines to stdout. Where the file to be read is specified on the command line.Input sample:Your progra原创 2013-01-01 19:29:40 · 547 阅读 · 0 评论 -
回调函数
在Java中,就是类A调用类B中的某个方法b,然后类B又在某个时候反过来调用类A中的某个方法a,对于A来说,这个a方法便叫做回调方法pubilc interface CallBack{ public void callbackMethod(); } public class A implements CallBack{ //转载 2014-11-27 13:27:06 · 552 阅读 · 0 评论