Algorithm
screaming
这个作者很懒,什么都没留下…
展开
-
Python - Search Insert Position
【LeetCode with Python】 Search Insert Position 标签: LeetCodeLeetCode with PythonPython2014-09-21 17:50 1027人阅读 评论(0) 收藏 举报 分类:LeetCode with Python(103) 版权声明:本文为博主原创文章,未经博主允转载 2016-01-16 19:52:32 · 579 阅读 · 0 评论 -
binary search tree
数据结构学习笔记二:二叉查找树二叉查找树的特点:(1)左边的所有节点都要小于根节点的值(2)右边的所有节点都要不小于根节点的值(3)原树的子树都符合(1)(2)条件。二叉查找树又名二叉排序树,因为只需中序遍历它就可以得到排序的树了,对于二叉排序树的操作主要有:(1)插入:通过插入来初始化树。本文是用链式,而不是存储在数组中。(转载 2016-06-01 10:14:04 · 331 阅读 · 0 评论 -
interview sorting algorithm summary
面试中的排序算法总结2016/04/25 · IT技术 · 1 评论 · 技术面试, 算法分享到:0原文出处: 大海里的太阳 前言查找和排序算法是算法的入门知识,其经典思想可以用于很多算法当中。因为其实现代码较短,应用较常见。所以在面试中经常会问到排序算法及其相关的问题。但万变不离其宗,只要熟悉了思想,灵活运用也不是难事。一般在面试中转载 2016-05-22 22:33:47 · 379 阅读 · 0 评论 -
Trie
TrieWhat is a trie:You've probably already seen kinds of trees that store things more efficiently, such as a binary search tree. Here, we will examine another variant of a tree, called a tri转载 2016-06-04 23:11:35 · 606 阅读 · 0 评论 -
word chains ruby
Word Chains (#44)Our own Dave Thomas has also posted some Ruby code challenges on his blog in the past. There are several interesting problems there:CodeKataThis week's Ruby Quiz is one of my fa转载 2016-06-11 14:53:02 · 451 阅读 · 0 评论 -
word ladder
[leetcode]Word Ladder II @ Python[leetcode]Word Ladder II @ Python原题地址:http://oj.leetcode.com/problems/word-ladder-ii/参考文献:http://blog.csdn.net/doc_sgl/article/details/13341405转载 2016-06-11 23:23:36 · 340 阅读 · 0 评论 -
电梯调度算法 summary
[转] 电梯调度算法总结1.传统电梯调度算法1.1先来先服务算法(FCFS)先来先服务(FCFS-First Come First Serve)算法,是一种随即服务算法,它不仅仅没有对寻找楼层进行优化,也没有实时性的特征,它是一种最简单的电梯调度算法。它根据乘客请求乘坐电梯的先后次序进行调度。此算法的优点是公平、简单,且每个乘客的请求都能依次地得到处理,不会出现转载 2016-06-11 23:32:42 · 926 阅读 · 0 评论 -
how to find list of possible words from letter matrix
How to find list of possible words from a letter matrix [Boggle Solver]up vote338down votefavorite274Lately I have been playing a game on my iPhone called Scram转载 2016-06-12 07:03:35 · 2779 阅读 · 0 评论 -
trapping water
LeetCode:Container With Most Water,Trapping Rain WaterContainer With Most Water题目链接Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n转载 2016-06-12 07:06:02 · 309 阅读 · 0 评论 -
BFS (Level Order Traversal)
【算法入门】广度/宽度优先搜索(BFS)博客分类: 算法C++算法 本文章已收录于: 算法与数据结构 广度/宽度优先搜索(BFS)【算法入门】郭志伟@SYSU:raphealguo(at)qq.com2012/04/271.前言广度优先搜索(也称宽度优先搜索,缩写BFS,以下采用广度来描述)是连通图的一种遍历策略。因转载 2016-06-13 18:07:05 · 312 阅读 · 0 评论 -
Rat in a Maze
Geeks 面试题: Rat in a Maze 回溯法解迷宫 标签: Geeks面试题Rat in a Maze回溯法解迷宫2014-01-13 08:09 1632人阅读 评论(3) 收藏 举报 分类: Algorithm算法(567) 版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23转载 2016-06-17 22:53:49 · 776 阅读 · 0 评论 -
knight's
psov-itBLOGGING HUBMenuWidgetsSocial LinksSearchA Knight’s WatchRecently I came across this interesting problem through Toptal (on Codility) which kept me t转载 2016-06-17 23:19:19 · 930 阅读 · 0 评论 -
K most frequent words from a file
The Most Efficient Way To Find Top K Frequent Words In A Big Word Sequenceup vote46down votefavorite34Input: A positive integer K and a big text. The text can a转载 2016-06-18 15:50:49 · 1059 阅读 · 0 评论 -
python heapq
python heapq这个模块(build-in)实现了一个堆的数据结构,完美的解决了Top-K问题,以后解决Top-K问题的时候,直接把这个模块拿来用就可以了注意,默认的heap是一个小顶堆! heapq模块提供了如下几个函数:heapq.heappush(heap, item) 把item添加到heap中(heap是一个列表)heapq.he转载 2016-06-18 18:50:03 · 642 阅读 · 0 评论 -
外排序
外排序 2013-09-15 21:57 2448人阅读 评论(0) 收藏 举报 分类: 算法(604) 数据结构(202) 目录(?)[+]外排序[编辑]4、最佳归并树:如果在进行多路归并的时候,各初始顺串的长度不同,对外存扫描的次数,即执行时间会产生影响。把所有初始顺串的块数作为树的叶结点的权值,转载 2016-06-19 13:41:30 · 1023 阅读 · 0 评论 -
Complexities Table
Know Thy Complexities!Hi there! This webpage covers the space and time Big-O complexities of common algorithms used in Computer Science. When preparing for technical interviews in the past, I fo转载 2016-10-31 16:43:40 · 568 阅读 · 0 评论 -
ugly numbers
Ugly NumbersUgly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, …shows the first 11 ugly numbers. By convention, 1 is included.转载 2016-06-01 10:09:31 · 485 阅读 · 0 评论 -
Triangle inequality
Triangle inequalityFrom Wikipedia, the free encyclopediaThis article is about the basic inequality z ≤ x + y. For other inequalities associated with triangles, see List of triangle i转载 2016-05-24 22:10:57 · 2989 阅读 · 0 评论 -
Recursion Vs Iteration
深究递归和迭代的区别、联系、优缺点及实例对比1.概念区分递归的基本概念:程序调用自身的编程技巧称为递归,是函数自己调用自己.一个函数在其定义中直接或间接调用自身的一种方法,它通常把一个大型的复杂的问题转化为一个与原问题相似的规模较小的问题来解决,可以极大的减少代码量.递归的能力在于用有限的语句来定义对象的无限集合.使用递归要注意的有两点:1)递归就是在过程或转载 2016-01-26 17:38:59 · 866 阅读 · 0 评论 -
recursion versus iteration
33down votefavorite13Is it correct to say that everywhere recursion is used a for loop could be used? And if recursion is usually slower what is the technical reason for ever using it ov转载 2016-01-27 23:36:53 · 381 阅读 · 0 评论 -
递归回溯
搜索的本质是枚举.回溯是最常用的搜索方法之一,它采用深度优先的策略来枚举所有可能的解,结合题设条件的限定,从而得到问题的解.回溯(backtracking)是一种系统地搜索问题解答的方法。为了实现回溯,首先需要为问题定义一个解空间(solution space),这个空间必须至少包含问题的一个解(可能是最优的)。 下一步是组织解空间以便它能被容易地搜索。典型的组织方转载 2016-01-11 16:08:42 · 4167 阅读 · 0 评论 -
穷举递归和回溯算法终结篇
factorial 英 [fæk'tɔːriəl] 美 [fæk'tɔːriəl] adj.阶乘的;因数的;工厂的;代理商的n.阶乘Noun:the product of all the integers up to and including a given integer;"1, 2, 6, 24, and 120 are fa转载 2016-01-11 16:52:34 · 806 阅读 · 0 评论 -
Exhaustive recursion and backtracking
Reference: https://see.stanford.edu/materials/icspacs106b/H19-RecBacktrackExamples.pdfCS106BJ ZelenskiHandout #19Feb 1, 2008Exhaustive recursion and backtrackingIn转载 2016-01-11 20:36:42 · 561 阅读 · 0 评论 -
递归算法的时间复杂度终结篇
NOTE: 博主python27对本博客文章享有版权,网络转载请注明出处http://www.cnblogs.com/python27/。对解题思路有任何建议,欢迎在评论中告知。【算法16】递归算法的时间复杂度终结篇 开篇前言:为什么写这篇文章?笔者目前在学习各种各样的算法,在这个过程中,频繁地碰到到递归思想和分治思想,惊讶于这两种的思想的伟大与奇妙的同时,经常要转载 2016-01-11 21:02:40 · 409 阅读 · 0 评论 -
BinarySearch
转载请注明:http://blog.csdn.net/zhouyelihua/article/details/46665931二分查找的应用二分查找作为O(log(n))时间复杂度的查找算法得到了广泛的使用。1.在已排序的数组中查找特定的元素。或者是满足条件的第一个元素 2.数学常用的求解方程的解,也是数学家所指的对半查找。 3.程序调试中用来定位错误语句转载 2016-01-12 22:41:43 · 234 阅读 · 0 评论 -
Level Order Tree Traversal
Level Order Tree TraversalLevel order traversal of a tree is breadth first traversal for the tree.Example TreeLevel order traversal of the above tree is 1 2 3 4 5 METHOD 1 (Use function转载 2016-03-02 14:23:35 · 475 阅读 · 0 评论 -
Maximum Difference Between Two Elements
Maximum difference between two elements such that larger element appears after the smaller numberGiven an array arr[] of integers, find out the difference between any two elements such that larg转载 2016-03-18 14:35:53 · 488 阅读 · 0 评论 -
Subarray Substring vs Subsequence
Subarray/Substring vs Subsequence and Programs to Generate themSubarray/SubstringA subbarray is a contiguous part of array. An array that is inside another array. For example, consider the转载 2016-03-18 17:11:45 · 633 阅读 · 0 评论 -
maximum subarray
最大子串和问题(Maximum Subarray) 标签: 算法2011-10-10 16:46 14186人阅读 评论(11) 收藏 举报版权声明:本文为博主原创文章,未经博主允许不得转载。又一个经典问题,对于一个包含负值的数字串array[1...n],要找到他的一个子串array[i...j](0这里我们需要注意子串和子序列之间的区别。子串是指转载 2016-03-18 22:00:01 · 224 阅读 · 0 评论 -
Divide and Conquer
Divide and Conquer | Set 1 (Introduction)Like Greedy and Dynamic Programming, Divide and Conquer is an algorithmic paradigm. A typical Divide and Conquer algorithm solves a problem using follo转载 2016-02-25 15:55:21 · 391 阅读 · 0 评论 -
Fibonacci numbers
Program for Fibonacci numbersThe Fibonacci numbers are the numbers in the following integer sequence.0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 141, ……..In mathematical terms, the sequence转载 2016-04-06 21:12:06 · 1211 阅读 · 0 评论 -
Count ways to reach the n’th stair
Count ways to reach the n’th stairThere are n stairs, a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs at a time. Count the number of ways,转载 2016-04-06 22:09:41 · 353 阅读 · 0 评论 -
Find subarray with given sum
Find subarray with given sumGiven an unsorted array of nonnegative integers, find a continous subarray which adds to a given number. Examples:Input: arr[] = {1, 4, 20, 3, 10, 5}, sum = 33转载 2016-04-07 22:33:25 · 771 阅读 · 0 评论 -
How do you design a rand7 function
How do you design a rand7 function using a rand5 function?My solution is:def rand7(): n = rand5() + rand5() + rand5() + rand5() + rand5() + rand5() + rand5() + rand5()转载 2016-11-12 23:11:17 · 510 阅读 · 0 评论