最新文章列表

LeetCode[动态规划] - #10 Regular Expression Matching

原题链接:#10 Regular Expression Matching   要求: 实现正则表达式匹配,支持'.'和'*'。   '.'匹配任意单字符。 '*'匹配任何0个或多个之前元素。   匹 ...
Cwind 评论(0) 有6437人浏览 2015-07-20 12:25

LeetCode[动态规划] - #7 Climbing Stairs

原题链接:#7 Climbing Stairs   问题: 你正在攀爬一把一共有n个台阶的梯子,每次可以爬一或二阶,爬到顶共有多少种不同的方式?   难度:简单   分析: 当梯子阶数为0时,有0种攀爬方式;当阶数为1时,则有一种攀爬方式。当阶数为2时,由于每次可以爬一阶或两阶,即从0阶处爬两阶到达顶部或由1阶处爬1阶到达顶处,共2种方式。n=3时同样,可以由1阶处爬两阶或由2阶处 ...
Cwind 评论(0) 有2113人浏览 2015-07-19 23:03

LeetCode[Math] - #7 Reverse Integer

原题链接:#7 Reverse Integer   要求: 按位反转输入的数字 例1: 输入 x = 123, 返回 321 例2: 输入 x = -123, 返回 -321   难度:简单   分析: 对于一般情况,首先保存输入数字的符号,然后每次取输入的末位(x%10)作为输出的高位(result = result*10 + x%10)即可。但须考虑边界情况,即输入大于In ...
Cwind 评论(0) 有1501人浏览 2015-07-18 23:10

LeetCode[Math] - #66 Plus One

原题链接:#66 Plus One   要求: 给定一个用数字数组表示的非负整数,如num1 = {1, 2, 3, 9}, num2 = {9, 9}等,给这个数加上1。 注意: 1. 数字的较高位存在数组的头上,即num1表示数字1239 2. 每一位(数组中的每个元素)的取值范围为0~9   难度:简单   分析: 题目比较简单,只须从数组尾部开始,若当前位是9则向前一 ...
Cwind 评论(0) 有2545人浏览 2015-07-18 22:57

LeetCode[位运算] - #137 Single Number II

原题链接:#137 Single Number II  要求: 给定一个整型数组,其中除了一个元素之外,每个元素都出现三次。找出这个元素 注意:算法的时间复杂度应 ...
Cwind 评论(0) 有3537人浏览 2015-07-18 22:18

Algorithm

冒泡排序 public static void sort(Integer[] param) { for (int i = param.length - 1; i > 0; i--) { for (int j = 0; j < i; j++) { int current = param[j]; int next = param[j + 1]; ...
香水浓 评论(0) 有523人浏览 2015-06-06 04:23

LeetCode[Math] - #9 Palindrome Number

原题链接:#9 Palindrome Number   要求: 判断一个整数是否是回文数,不要使用额外的存储空间   难度:简单   分析: 题目限制不允许使用额外的存储空间应指不允许使用O(n)的内存空间,O(1)的内存用于存储中间结果是可以接受的。于是考虑将该整型数反转,然后与原数字进行比较。 注:没有看到有关负数是否可以是回文数的明确结论,例如-1,-121等。根据Lee ...
Cwind 评论(0) 有2027人浏览 2015-03-24 18:42

LeetCode[位运算] - #136 数组中的单一数

原题链接:#136 Single Number 要求: 给定一个整型数组,其中除了一个元素之外,每个元素都出现两次。找出这个元素 注意:算法的时间复杂度应为O(n),最好不使用额外的内存空间 难度:中等 分析: 题目限定了线性的时间复杂度,同时不使用额外的空间,即要求只遍历数组一遍得出结果。由于异或运算 n XOR n = 0, n XOR 0 = n,故将数组中的每个元素进行异或运 ...
Cwind 评论(0) 有1477人浏览 2015-03-20 08:21

LeetCode[位运算] - #191 计算汉明权重

原题链接:#191 Number of 1 Bits 要求: 写一个函数,以一个无符号整数为参数,返回其汉明权重。例如,‘11’的二进制表示为'00000000000000000000000000001011', 故函数应当返回3。 汉明权重:指一个字符串中非零字符的个数;对于二进制串,即其中‘1’的个数。 难度:简单 分析: 将十进制参数转换为二进制,然后计算其中1的个数即可。 ...
Cwind 评论(4) 有3175人浏览 2015-03-18 19:29

Algorithm算法视频教程

课程:Algorithm算法视频教程 百度网盘下载地址: http://pan.baidu.com/s/1qWFjjQW 密码: 2mji 程序写的好不好,还得看算法屌不屌!Algorithm算法博大精深。 一、课程内容: 课时1、算法的基本概念 + Sequential search 课时2、Binary search 课时3、Hash table 课时4、Algorithm_Week1 ...
栏目记者 评论(0) 有654人浏览 2015-02-09 10:39

细数二十世纪最伟大的十大算法

转自<http://blog.csdn.net/v_july_v/article/details/6127953> 译者:July   二零一一年一月十日 ------------------------------------ 参考文献:The Best of the 20th Century: Editors Name Top 10 Algorithms。By Barry A ...
gaylord 评论(0) 有579人浏览 2014-07-20 11:06

算法复杂度

Time Complexity & Big-O: http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o http://bigocheatsheet.com/ http://www.sitepoint.com/time-complexity-algorithms/ 什么是P问题、NP问题和 ...
Wuaner 评论(0) 有902人浏览 2014-02-19 15:46

leetcode: sort list

Sort a linked list in O(n log n) time using constant space complexity. ====analysis======= mergeSort for singly-linked list  ====code=======   /** * Definition for singly-linked list. * struct Li ...
michelle_0916 评论(0) 有390人浏览 2014-02-02 03:49

基础数据结构和算法十四:Directed Graphs

  In directed graphs, edges are one-way: the pair of vertices that defines each edge is an ordered pair that specifies a one-way adjacency. Many applications (for example, graphs that represent the w ...
sunwinner 评论(0) 有1762人浏览 2013-12-15 22:40

基础数据结构和算法十三:Undirected Graphs (2)

  Design pattern for graph processing. Since we consider a large number of graph-processing algorithms, our initial design goal is to decouple our implementations from the graph representation. To ...
sunwinner 评论(0) 有1018人浏览 2013-12-13 22:51

基础数据结构和算法十三:Undirected Graphs

A graph is a set of vertices and a collection of edges that each connect a pair of vertices. Vertex names are not important to the definition, but we need a way to refer to vertices. By convention, w ...
sunwinner 评论(0) 有1167人浏览 2013-12-13 20:15

基础数据结构和算法十一:Red-black binary search tree

  The insertion algorithm for 2-3 trees just described is not difficult to understand; now, we will see that it is also not difficult to implement. We will consider a simple representation known as ...
sunwinner 评论(0) 有1484人浏览 2013-12-01 12:12

基础数据结构和算法十:2-3 search tree

  Binary search tree works well for a wide variety of applications, but they have poor worst-case performance. Now we introduce a type of binary search tree where costs are guaranteed to be logarith ...
sunwinner 评论(0) 有1180人浏览 2013-11-30 11:07

基础数据结构和算法九:Binary Search Tree

  A binary search tree (BST) is a binary tree where each node has a Comparable key (and an associated value) and satisfies the restriction that the key in any node is larger than the keys in all nod ...
sunwinner 评论(0) 有1621人浏览 2013-11-28 22:39

基础数据结构和算法八:Binary search

Binary search needs an ordered array so that it can use array indexing to dramatically reduce the number of compares required for each search, using the classic and venerable binary search algorithm. ...
sunwinner 评论(0) 有1098人浏览 2013-11-28 21:21

最近博客热门TAG

Java(141744) C(73651) C++(68608) SQL(64571) C#(59609) XML(59133) HTML(59043) JavaScript(54919) .net(54785) Web(54514) 工作(54118) Linux(50905) Oracle(49875) 应用服务器(43289) Spring(40812) 编程(39454) Windows(39381) JSP(37542) MySQL(37267) 数据结构(36424)

博客人气排行榜

    博客电子书下载排行

      >>浏览更多下载

      相关资讯

      相关讨论

      Global site tag (gtag.js) - Google Analytics