上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 26 下一页
摘要: 236. 二叉树的最近公共祖先 题目描述 相似题目:https://www.cnblogs.com/GarrettWale/p/14406641.html 题解分析 此题是利用二叉树的后序遍历来求解最近公共祖先。 递归的出口是遍历到叶子结点或者当前结点(root)等于待搜索的结点(p或者q),此时需 阅读全文
posted @ 2021-03-12 22:49 Garrett_Wale 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 141. 环形链表 LeetCode_141 题目描述 实现思路 使用快慢指针的方法可以判断是否有环。 需要注意的是:在起始的时候不能把快慢指针都指向head,否则永远不会进入循环!!!! 代码实现 /** * Definition for singly-linked list. * class L 阅读全文
posted @ 2021-03-11 18:23 Garrett_Wale 阅读(63) 评论(0) 推荐(0) 编辑
摘要: 148. 排序链表 LeetCode_148 题目描述 题解分析 可以利用归并排序的思想对链表进行排序 要利用归并排序,首先就要得到中间结点,这个可以利用快慢指针来实现。 剩下的就是链表合并的问题,具体可以参考:https://www.cnblogs.com/GarrettWale/p/145142 阅读全文
posted @ 2021-03-10 21:13 Garrett_Wale 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 21. 合并两个有序链表 LeetCode_21 题目描述 解法一:迭代法 /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * 阅读全文
posted @ 2021-03-10 21:04 Garrett_Wale 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 189. 旋转数组 LeetCode_189 题目描述 方法一:使用暴力法 class Solution { public void rotate(int[] nums, int k) { int n = nums.length; int[] second = new int[n]; for(int 阅读全文
posted @ 2021-03-10 19:55 Garrett_Wale 阅读(55) 评论(0) 推荐(0) 编辑
摘要: Spark的五种JOIN策略解析 JOIN操作是非常常见的数据处理操作,Spark作为一个统一的大数据处理引擎,提供了非常丰富的JOIN场景。本文分享将介绍Spark所提供的5种JOIN策略,希望对你有所帮助。本文主要包括以下内容: 影响JOIN操作的因素 Spark中JOIN执行的5种策略 Spa 阅读全文
posted @ 2021-03-10 11:26 Garrett_Wale 阅读(507) 评论(0) 推荐(0) 编辑
摘要: 什么是零拷贝 WIKI中对其有如下定义: "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to anot 阅读全文
posted @ 2021-03-10 10:03 Garrett_Wale 阅读(757) 评论(0) 推荐(0) 编辑
摘要: 300. 最长递增子序列 题目描述 方法一:动态规划 与53. 最大子数组和 + 动态规划 + 线段树 问题类似,本题属于子序列问题的一种。 问题的关键是定义好dp动态方程,类似于LeetCode-53题目,我们假设dp[i]表示i结尾的递增子序列的长度。 对于状态转移方程,我们可以这样考虑:因为是 阅读全文
posted @ 2021-03-09 22:23 Garrett_Wale 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 596. 超过5名学生的课 LeetCode_MySql_596 题目描述 方法一:使用group by + where + 子查询 # Write your MySQL query statement below select c1.class from ( select class, count 阅读全文
posted @ 2021-03-09 20:28 Garrett_Wale 阅读(57) 评论(0) 推荐(0) 编辑
摘要: 958. 二叉树的完全性检验 LeetCode_958 题目描述 题解分析 题目的关键是判断每一层的结点数是否等于2^i。 此外,还有一个比较关键的因素是判断最后一层的结点是否是偏左的。 以上这两点都可以通过给每个结点设置一个序号,也就是按照二叉树的顺序存储的方式分配序号,如果最后一个结点的序号和所 阅读全文
posted @ 2021-03-09 20:13 Garrett_Wale 阅读(72) 评论(0) 推荐(0) 编辑
摘要: explain ​ explain模拟优化器执行SQL语句,在5.6以及以后的版本中,除过select,其他比如insert,update和delete均可以使用explain查看执行计划,从而知道mysql是如何处理sql语句,分析查询语句或者表结构的性能瓶颈。 作用 1、表的读取顺序 2、数据读 阅读全文
posted @ 2021-03-09 10:56 Garrett_Wale 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 题目来源 LeetCode_42 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 题目详情 示例 1: 输入: height = [0,1,0,2,1,0,1,3,2,1,2,1] 输出: 6 解释: 上面是由数组 [0,1,0,2,1,0,1,3 阅读全文
posted @ 2021-03-08 21:12 Garrett_Wale 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 题目来源 LeetCode_53 题目描述 给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 子数组 是数组中的一个连续部分。 示例 1: 输入: nums = [-2,1,-3,4,-1,2,1,-5,4] 输出: 6 解释: 连续子数组  阅读全文
posted @ 2021-03-08 20:24 Garrett_Wale 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 103. 二叉树的锯齿形层序遍历 LeetCode_103 相似题型:剑指 Offer 32 - III. 从上到下打印二叉树 III 题目描述 LinkedList(Deque的一个实现类)的用法 增加: add(E e):在链表后添加一个元素; 通用方法 addFirst(E e):在链表头部插 阅读全文
posted @ 2021-03-08 19:57 Garrett_Wale 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 面试官: Java并发这块了解的怎么样?说说你对volatile关键字的理解 就我理解的而言,被volatile修饰的共享变量,就具有了以下两点特性: 1.保证了不同线程对该变量操作的内存可见性; 2.禁止指令重排序 面试官: 能不能详细说下什么是内存可见性,什么又是重排序呢? 这个聊起来可就多了, 阅读全文
posted @ 2021-03-07 21:45 Garrett_Wale 阅读(413) 评论(0) 推荐(0) 编辑
摘要: 题目来源 LeetCode_46 题目描述 给定一个不含重复数字的数组 nums ,返回其 所有可能的全排列 。你可以 按任意顺序 返回答案。 示例 1: 输入: nums = [1,2,3] 输出: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] 阅读全文
posted @ 2021-03-07 21:24 Garrett_Wale 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 232. 用栈实现队列 LeetCode_232 题目描述 方法一:在push时将原有栈的元素全部出栈然后再将当前元如入栈,最后再将第二个栈的元素入第一个栈 class MyQueue{ int num; Deque<Integer> sta1, sta2;//使用双端队列来模拟栈 /** Init 阅读全文
posted @ 2021-03-07 20:54 Garrett_Wale 阅读(73) 评论(0) 推荐(0) 编辑
摘要: 54. 螺旋矩阵 LeetCode_54 相似题目:剑指 Offer 29. 顺时针打印矩阵 题目描述 代码实现 class Solution { public List<Integer> spiralOrder(int[][] matrix) { int m = matrix.length;//行 阅读全文
posted @ 2021-03-07 20:23 Garrett_Wale 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 题目来源 LeetCode_69 题目详情 题解分析 方法一:使用sqrt class Solution { public int mySqrt(int x) { return (int)Math.sqrt((double)x); } } 方法二:袖珍计算器 class Solution { pub 阅读全文
posted @ 2021-03-07 20:04 Garrett_Wale 阅读(68) 评论(0) 推荐(0) 编辑
摘要: 197. 上升的温度 LeetCode_MySql_197 题目描述 代码实现 # Write your MySQL query statement below select we1.id Id from Weather we1, Weather we2 where datediff(we1.rec 阅读全文
posted @ 2021-03-06 22:45 Garrett_Wale 阅读(48) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 26 下一页