摘要: 面试官: Java并发这块了解的怎么样?说说你对volatile关键字的理解 就我理解的而言,被volatile修饰的共享变量,就具有了以下两点特性: 1.保证了不同线程对该变量操作的内存可见性; 2.禁止指令重排序 面试官: 能不能详细说下什么是内存可见性,什么又是重排序呢? 这个聊起来可就多了, 阅读全文
posted @ 2021-03-07 21:45 Garrett_Wale 阅读(414) 评论(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) 编辑