MAP 与 MRR 看论文时,发现对于wikiqa的评价指标常设为MAP、MRR这些Rank排序的指标,不是很理解,看了下面这篇博客有些理解了http://blog.csdn.net/lightty/article/details/47079017 在MAP中,四个文档和query要么相关,要么不相关,也就是相关度非0即1。MAP(Mean Average Precision):单个主题的平均准确率是每篇相关文档检索...
leetcode 329. Longest Increasing Path in a Matrix leetcode 329. Longest Increasing Path in a Matrix下面这个解法的错误之处在于,最长路径不会遵循左上 或 右上 这样的法则,可以同时包含两种模式。class Solution { public int longestIncreasingPath(int[][] matrix) { int m = matrix
leetcode 333. Largest BST Subtree leetcode 333. Largest BST Subtree/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val =
leetcode 265. Paint House II leetcode 265. Paint House IIclass Solution { public int minCostII(int[][] costs) { int N = costs.length; if(N==0) return 0; int k = costs[0].length; if(k=
【dp】leetcode 276. Paint Fence 【dp】leetcode 276. Paint Fenceclass Solution { public int numWays(int n, int k) { if(n==0||k==0) return 0; int[][][] dp = new int[n+1][k][2]; for(int j=0;j<k;j++){
leetcode 542. 01 Matrix bfs: 先0后1 再1后1dp: 从左上到右下,从右下到左上https://leetcode.com/problems/01-matrix/solution/#approach-2-using-bfs-accepted
RNN Summarization quora 数据集:https://www.quora.com/Has-Deep-Learning-been-applied-to-automatic-text-summarization-successfully
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
【二叉搜索树:删除指定结点】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
【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 {
【平衡二叉树】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;
【tree】【 由中根序遍历与后根序遍历生成树】【由先根序与中根序遍历生成树】 递归思想,找到根节点,问题便分解为左子树与右子树leetcode 106. Construct Binary Tree from Inorder and Postorder Traversal/** * Definition for a binary tree node. * public class TreeNode { * int val; * Tr
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
【矩阵子阵求和问题】 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
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
leetcode 484. Find Permutation leetcode 484. Find Permutation 贪心算法全靠细心,思路简单:初始: S[0] = 'I', 设为1。cur 变量用来记录前面最大的值(因为所求的为置换关系),后续有多少个D,则当前写入最大的值,后续依次减小就可以。class Solution(object): def findPermutation(self, s): """
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
leetcode 625. Minimum Factorization leetcode 625. Minimum Factorization题目中给的是最小的,所以思考时从2开始想起,陷入怎样将多个2组合,比较混乱。从9开始,把大的因子取出来,很多问题都可以用贪心的办法来解决,关键是要找到贪心的策略public class Solution { public int smallestFactorization(int a) {
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();