- 博客(11)
- 收藏
- 关注
原创 Median of Two Sorted Arrays C++
这道题目很多人认为是leetcode上最经典的题目之一,很早之前就见过这个题目,好像算法导论也有讲过这个题。题意是找两个排好序的数组的中位数,如果不去考虑时间空间复杂度,这个问题极其简单,用merge排序将一个数组归并到另一个数组中去,然后就可以立马找到中位数,不过这样的时间空间复杂度都比较高,其实,按照这个思路写出来的代码也可以AC,可见leetcode的AC标准也不是很严格。那么这个题有没
2015-09-24 16:25:47 520
原创 Trapping Rain Water C#
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]
2015-09-23 16:36:14 479
原创 Ugly Number I II 解析
leetcode上关于ugly number(丑数)的题目有两个,先说一下什么叫丑数,很多博客上关于丑数的解释有比较模糊,有的解释成能被2,3,5整除的数,这是很难理解的一句话,比如14,35明明可以被2和5整除却不是丑数。其实丑数是一种能写成2,3,5的乘方组合(number == 2^m*3^n*5^k,m,n,k为自然数)的形式的数字,比如 180这个数字,可以写成2*2*3*3*5,它
2015-09-15 18:20:28 450
原创 单例模式简介及在WinForm编程中的实现方法
单例模式是在设计模式中经常使用的一种,顾名思义就是实现一个只能创建一个实例对象的类。刚接触面向对象的coder可能比较难理解这种模式有何意义,其实举个例子来讲就比较好理解了:很多人都喜欢打网游,你打开一个登陆器登陆上自己的账号后又想登陆一个别的账号,但是还不想关闭当前这个账号,一般情况下你再打开遍登陆器就可以实现了,此时这些登陆窗口的实现就不是单利模式了。当你登陆游戏后进入你的人物界面,你点击人物
2015-09-14 09:28:26 2131 1
原创 Generate Parentheses C++
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()
2015-09-11 14:37:12 402
原创 Number of Islands C++
Given a 2d grid map of '1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assum
2015-09-11 10:09:33 1203
原创 Valid Parentheses C#
Given a string containing just the characters '(', ')', '{', '}', '[' and']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all val
2015-09-08 15:35:00 430
原创 ZigZag Conversion (C实现)
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H NA P L S I
2015-09-08 14:40:11 1085
原创 Divide Two Integers C#
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.题意:实现一个除法,不能用division,mod,multiplication这三种运算。当然了能用division,写个毛线啊。这些都不能用,运算里面只有加法了
2015-09-07 13:55:53 540
原创 Fraction to Recurring Decimal C#
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose the repeating part in parentheses.For
2015-09-06 15:34:03 496
原创 Manacher算法之个人愚见
这个俗称“马拉车”的算法的适用问题比较局限,是Manacher在解决寻找字符串中最长回文时提出的一种时间复杂度为O(n)的算法。废话不多说,直接讲算法:字符串预处理首先,在解决回文类型的算法题目时,经常会很头疼的问题就是最终解的回文中字符总数是奇数还是偶数,即abba与aba两种类型,比如判断一个字符串是不是回文就要区别对待这两种情况。但在Manacher算法中首先针对这个问题提出了解决办
2015-09-06 10:50:38 401
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人