- 博客(15)
- 收藏
- 关注
原创 leetcode 542. 01 Matrix
bfs: 先0后1 再1后1dp: 从左上到右下,从右下到左上https://leetcode.com/problems/01-matrix/solution/#approach-2-using-bfs-accepted
2017-08-15 00:37:28 556
原创 RNN Summarization
quora 数据集:https://www.quora.com/Has-Deep-Learning-been-applied-to-automatic-text-summarization-successfully
2017-08-12 23:55:25 514
原创 leetcode Add to List 425. Word Squares
leetcode Add to List 425. Word Squareszip(*) 当前列就是下一行的前缀,用这个来遍历, square 为4时输出方阵。class Solution(object): def wordSquares(self, words): """ :type words: List[str] :rty
2017-08-12 21:41:09 522
原创 【二叉搜索树:删除指定结点】leetcode 450. Delete Node in a BST
leetcode 450. Delete Node in a BST/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x
2017-08-12 16:22:38 374
原创 【tree 反转二叉树 inverse binary tree】
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution {
2017-08-12 15:52:59 393
原创 【平衡二叉树】leetcode 110. Balanced Binary Tree
leetcode 110. Balanced Binary Tree/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x;
2017-08-12 14:54:39 357
原创 【tree】【 由中根序遍历与后根序遍历生成树】【由先根序与中根序遍历生成树】
递归思想,找到根节点,问题便分解为左子树与右子树leetcode 106. Construct Binary Tree from Inorder and Postorder Traversal/** * Definition for a binary tree node. * public class TreeNode { * int val; * Tr
2017-08-12 12:43:44 653
原创 leetcode 289. Game of Life
leetcode 289. Game of Life谷歌的面试题果然很开眼界,比如这题,用两bit来表示前后两次的状态,很巧妙。public class Solution { public void gameOfLife(int[][] board) { if(board==null||board.length==0) return; int m
2017-08-09 23:02:14 342
原创 【矩阵子阵求和问题】 leetcode 308. Range Sum Query 2D - Mutable
// package my;public class NumMatrix { public static void main(String[] args){ int[][] examp = new int[2][2]; NumMatrix obj = new NumMatrix(examp); obj.update(0,0,1);// System.out.println
2017-08-06 16:23:58 888
原创 leetcode 146. LRU Cache 链表操作与缓存处理
public class LRUCache { class DlinkedNote{ int key; int value; DlinkedNote pre; DlinkedNote post; DlinkedNote(){} DlinkedNote(int key, int value){ this.key = ke
2017-08-06 12:11:26 789
原创 leetcode 484. Find Permutation
leetcode 484. Find Permutation 贪心算法全靠细心,思路简单:初始: S[0] = 'I', 设为1。cur 变量用来记录前面最大的值(因为所求的为置换关系),后续有多少个D,则当前写入最大的值,后续依次减小就可以。class Solution(object): def findPermutation(self, s): """
2017-08-06 10:34:22 979
原创 leetcode 545. Boundary of Binary Tree
leetcode 545. Boundary of Binary Tree这一题考察的是树型的先序遍历,三角形正好是先序遍历的访问点,需要做的工作就是识别出是否为边界,在下面的代码中全靠flag变量来处理参考solution : https://leetcode.com/problems/boundary-of-binary-tree/discuss/public clas
2017-08-05 21:58:39 653
原创 leetcode 625. Minimum Factorization
leetcode 625. Minimum Factorization题目中给的是最小的,所以思考时从2开始想起,陷入怎样将多个2组合,比较混乱。从9开始,把大的因子取出来,很多问题都可以用贪心的办法来解决,关键是要找到贪心的策略public class Solution { public int smallestFactorization(int a) {
2017-08-05 16:35:59 900
原创 leetcode 340. Longest Substring with At Most K Distinct Characters
leetcode 340. Longest Substring with At Most K Distinct Characters下面的实现是很直观的,记下当前所包含的字符数,采用双指针进行移动public class Solution { public static void main(String[] args){ Solution s = new Solution();
2017-08-01 23:32:37 529
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人