![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
文章平均质量分 70
imabluefish
这个作者很懒,什么都没留下…
展开
-
判断是否字符串重组 Scramble String @LeetCode
三维动态规划题目:原创 2014-08-17 15:35:06 · 1383 阅读 · 0 评论 -
SearchMatrix@Leetcode
只需要将此二维数组视为一维数组,然后对它进行binary search即可。public class Solution { public boolean searchMatrix(int[][] matrix, int target) { if (matrix == null || matrix.length == 0 || matrix[0].length原创 2014-09-15 10:47:06 · 847 阅读 · 0 评论 -
Longest Substring Without Repeating Characters 最长不重复子串 @LeetCode
Ref: http://fisherlei.blogspot.com/2012/12/leetcode-longest-substring-without.html原创 2014-08-18 16:47:21 · 1652 阅读 · 0 评论 -
Sudoku Solver 破解数独@LeetCode - CSDN blog
DFS的题目,为了简化逻辑,我e代码如下: public class Solution { // ref: http://blog.csdn.net/fightforyourdream/article/details/16916985 public void solveSudoku(char[][] board) { if (board ==原创 2014-08-19 18:50:39 · 619 阅读 · 0 评论 -
Regular Expression Matching @LeetCode
代码如下:package Algorithms;public class IsMach { public static void main(String[] str) { //System.out.println(isMatch("aa", "aa")); System.out.println(isMatch("aab", "c*a*b")原创 2014-09-12 16:52:29 · 978 阅读 · 0 评论 -
Restore IP Addresses @Leetcode
https://oj.leetcode.com/problems/restore-ip-addresses/这道题的解法非常接近于NP问题,也是采用递归的解法。基本思路就是取出一个合法的数字,作为IP地址的一项,然后递归处理剩下的项。可以想象出一颗树,每个结点有三个可能的分支(因为范围是0-255,所以可以由一位两位或者三位组成)。并且这里树的层数不会超过四层,因为IP地址由四段组成,到了之后原创 2014-09-11 14:42:55 · 929 阅读 · 0 评论 -
LeetCode 高频题目
LeetcodeSingle Number II LeetcodeSingle NumberLeetcodeBest Time to Buy and Sell Stock IIILeetcodeBest Time to Buy and Sell Stock IILeetcodeBest Time原创 2014-08-25 17:22:39 · 6001 阅读 · 0 评论 -
Single Number II @LeetCode
public class Solution { public int singleNumber(int[] A) { if (A == null) { return 0; } int ret = 0; for (int i = 0; i int原创 2014-08-25 16:06:20 · 2909 阅读 · 0 评论 -
Single Number @LeetCode
相当简单的题目使用异或就能解决了。因为A XOR A = 0;原创 2014-08-25 15:25:54 · 547 阅读 · 0 评论 -
Divide Two Integers @LeetCode
自己想根本没有想到解,谷歌了一下答案,发现是每减一次除数即使原创 2014-08-21 11:29:39 · 551 阅读 · 0 评论 -
Surrounded Regions @LeetCode
几个月不做 再看仍然是相当麻烦的一道jghh原创 2014-08-22 15:51:13 · 468 阅读 · 0 评论 -
[LeetCode] Longest Palindromic Substring 解题报告
DP solution定义函数P[i,j] = 字符串区间[i,j]是否为palindrome.首先找个例子,比如S="abccb", S= a b c c bIndex = 0 1 2 3 4P[0,0] =1 //each char is a palindromeP[0,1] =S[0] == S[1] , P[1,1]原创 2014-08-20 11:19:42 · 645 阅读 · 0 评论 -
FindLongest path 某STARTUP 面试题目
找树中同方向的最长路径。例如: 2 1 23 4 8 9原创 2014-09-18 13:01:33 · 728 阅读 · 0 评论 -
Merge Intervals @LeetCode
Ref : http://fisherlei.blogspot.com/2013/04/leetcode-merge-intervals-solution.html原创 2014-08-20 09:20:50 · 1230 阅读 · 0 评论 -
Insert Interval @LeetCode
想象一下,先将New 放在那里,然后将所有原来的Interval一个一个加/** * Definition for an interval. * public class Interval { * int start; * int end; * Interval() { start = 0; end = 0; } * Interval(i原创 2014-08-20 08:32:52 · 438 阅读 · 0 评论 -
Triangle 三角形求最小路径和 @leetcode
动态规划的题目,f[i][j] 表示某hkpublic class Solution { public int minimumTotal(ArrayList> triangle) { int n = triangle.size(); int sum[][] = new int[n][n];原创 2014-08-18 10:06:28 · 969 阅读 · 2 评论 -
Palindrome Partitioning II @LeetCode
分割回文串-Leetcode 面试题原创 2014-09-25 07:21:43 · 696 阅读 · 0 评论