- 浏览: 201498 次
- 性别:
- 来自: 杭州
最新评论
-
hthhit:
...
回溯算法之N皇后问题(java实现) -
huntfor:
249326109 写道这个算法的复杂度有考虑过么O(n^2) ...
[leetcode]Longest Valid Parentheses -
249326109:
这个算法的复杂度有考虑过么
[leetcode]Longest Valid Parentheses -
huntfor:
249326109 写道又搜到你的了 你怎么搜的,为啥我搜不到 ...
[leetcode]Sort Colors -
249326109:
又搜到你的了
[leetcode]Sort Colors
文章列表
这几天做毕设,用到Hibernate,发现buildSessionFactory方法,上网找资料得到的答案如下:
public void test() {
Configuration cfg = new Configuration();
cfg.configure();
ServiceRegistry sr = new ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry();
SessionFactory sf = cfg.buildS ...
记录每次遇到的bug与异常
jdbc的下载地址与DBMS的配制方法见下文http://www.360doc.com/content/14/0806/02/15319145_399731507.shtml
我在测试链接的时候遇到了如下异常:
数据库驱动加载成功...com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'sa' 登录失败。 ClientConnectionId:ea4142b1-ae5c-4618-b6a5-c827b5205235 at com.microsoft.sqlserver.jdbc.SQLServe ...
又是一篇漏网之鱼,请大家移步新博文地址:[leetcode]Add Two Numbers
Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.
Input: (2 -> 4 -& ...
新博文地址:[leetcode]Remove Duplicates from Sorted Array II
Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is now [1,1,2,2,3] ...
新博文地址:[leetcode]Reorder List
Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to {1,4,2,3}.
算法思路:
设置快慢指针将前半段与后半段分开,然后将后半段逆序,再逐个插入前半段,时间复杂度O(n) ...
这道题包含在难度一的习题汇总里面。现在单独列出来。
新博文换了一种思路,代码更简洁,空间更节省
新博文地址:[leetcode]Plus One
Plus One
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.
题目大意是,一个非负数用数组表示,对这个数+1,返回+1后的数组结 ...
终于刷完一遍了【搬家】
- 博客分类:
- 吐槽
博客搬家鸟,请戳这里:
喵星人与汪星人
第二遍刷才发现第一遍的代码有多愁淫....新博文的算法,无论是在复杂度,还是代码简洁度、可读性上,都要优于本博客的代码,建议大家看博客的时候,直接点新博文地址。新博文不断更新中
终于刷完一遍了,马克一下
151道题目,完全自己做的大概有120+道左右,借鉴别人思路的大概20道左右,抄的大概10道左右.....
leetcode151道题目应该在本博客中都有记载。
不容易
第二遍可能把博客搬家,搬家地址会更新在这篇博文中
第二遍会对每一道题进行优化,并对每类问题进行分类,并尽量在时间、空间、代码可读性上做的更好
以上
...
新博文地址:[leetcode]Sudoku Solver
Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.
好了,最后一道题了,一直对数独特别害怕,不知道为啥,但是仔细看了这道题,貌似没啥难度,跟八皇后问题一样,典型的回溯算法,当然也可以用迭代实现,我 ...
Scramble String
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr eat / \ / \ g r e at / \ a tTo ...
Word Ladder II
Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be changed at a timeEach intermediate word must exist in the dictionaryFor example,Given:start = "hit"end = "cog"dict ...
新博文地址:[leecode]Clone Graph
Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each node, and , as a separator for node label and each neighbor of the ...
Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
坐标轴上面有n个点,求共线的最大点数。
这道题是leetcode上通过率最低的,但是绝对不是最难的,几点共线我们可以根据y = k x + b算出:
1. 平行于y轴的垂线斜率设为最大值,平行于x轴的线与普通斜线没啥区别,不需要做特殊处理;
2. 比较棘手的是重复点
这道题,我重构了一个数据结构,包含了k,b从而确定了每一条线,二重遍历坐标轴中 ...
新博文地址:[leetcode]Binary Tree Maximum Path Sum
Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return 6.
这道题是非常好的一道题,树,常 ...
Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.
最土的做法无疑就是遍历矩阵中的所有矩形,时间复杂度为O(n^2 * m ^2)不用试估计也会超时了,看了讨论组里面有位大 ...
新博文地址:[leetcode]Interleaving String
建议大家看新博文,自己想的算法比本博文借鉴的算法要更容易理解。
Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbb ...