![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
junzhiL
我不生产知识,我只是知识的搬运工...
展开
-
leetcode 四道shell编程题目
leetcode-192 统计词频cat words.txt | tr -s ' ' '\n' | sort | uniq -c | sort -r | awk '{ print $2, $1 }'tr -s ' ' '\n' 将空格替换成回车,每个单词一行sort 按字典序排序,保证重复的行相邻uniq -c 去掉重复的行,-c...原创 2019-08-07 21:59:41 · 274 阅读 · 0 评论 -
Leetcode之PathSum问题
Path Sumleetcode - 112. Path Sumclass Solution { public boolean hasPathSum(TreeNode root, int sum) { if(root==null){ return false; } if(root.left==...原创 2019-08-01 18:24:25 · 177 阅读 · 0 评论 -
LCA-二叉树公共祖先问题
二叉搜索树leetcode 235. Lowest Common Ancestor of a Binary Search Treeclass Solution { public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if(root.val>p.val &am...原创 2019-07-30 16:56:57 · 160 阅读 · 0 评论 -
LeetCode-347 出现频率最多的 k 个数
leetcode-347. Top K Frequent Elements本文答案参考自leetcode评论区解法一:桶排序时间复杂度O(n)class Solution { public List<Integer> topKFrequent(int[] nums, int k) { Map<Integer,Integer> map = ...原创 2019-08-08 15:39:07 · 285 阅读 · 0 评论