- 博客(8)
- 收藏
- 关注
原创 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
392
原创 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
368
原创 Leetcode之PathSum问题
Path Sum leetcode - 112. Path Sum class Solution { public boolean hasPathSum(TreeNode root, int sum) { if(root==null){ return false; } if(root.left==...
2019-08-01 18:24:25
348
原创 LCA-二叉树公共祖先问题
二叉搜索树 leetcode 235. Lowest Common Ancestor of a Binary Search Tree class Solution { public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if(root.val>p.val &am...
2019-07-30 16:56:57
250
原创 牛客网中级项目第三课mysql连不上的问题com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not
我电脑上安装的mysql版本是8.0.17 在跑测试用例时,一直报错,提示连不上数据库:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to… 网上查了好久都说是因为代码中数据库驱动的版本和数据库版本不对应!又按照网上的方法都试了一遍,还是不行。最后把...
2019-07-29 23:52:33
364
原创 SQL LEFT JOIN
SQL-LEFT JOIN LEFT JOIN 关键字从左表(table1)返回所有的行,即使右表(table2)中没有匹配。如果右表中没有匹配,则结果为 NULL。 SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name=table2.column_name; 实例 select emp_no fro...
2019-07-16 23:50:12
430
原创 SQL_having
SQL HAVING HAVING 子句 在 SQL 中增加 HAVING 子句原因是,WHERE 关键字无法与聚合函数一起使用。 HAVING 子句可以让我们筛选分组(GROUP BY)后的各组数据。 实例 select emp_no,count(salary) as t from salaries group by emp_no having t>15 ...
2019-07-16 19:35:43
344
原创 链表反转总结
链表反转 单链表反转 leetcode 206 reverse-linked-list 递归解法 class Solution { public ListNode reverseList(ListNode head) { if(head==null || head.next==null){ return head; } ...
2019-07-03 00:03:54
408
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅