摘要: public class _42_接雨水 { /** * 空间复杂度O(1),时间复杂度O(n) */ public int trap(int[] height) { if (height == null || height.length == 0) return 0; int lastIdx = 阅读全文
posted @ 2021-07-06 16:40 syh-918 阅读(40) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/container-with-most-water/ */public class _11_盛最多水的容器 { public int maxArea(int[] height) { if (height == null | 阅读全文
posted @ 2021-07-06 16:24 syh-918 阅读(68) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/meeting-rooms-ii/ */public class _253_会议室_II { public int minMeetingRooms(int[][] intervals) { if (intervals == 阅读全文
posted @ 2021-07-06 14:51 syh-918 阅读(91) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/meeting-rooms/ */public class _252_会议室 { public boolean canAttendMeetings(int[][] intervals) { if (intervals == 阅读全文
posted @ 2021-07-06 14:42 syh-918 阅读(82) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/reverse-integer/ */public class _7_整数反转 { public int reverse1(int x) { long res = 0; while (x != 0) { res = res 阅读全文
posted @ 2021-07-06 14:07 syh-918 阅读(46) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/lru-cache/ */public class _146_LRU缓存机制 { public static void main(String[] args) { LRUCache cache = new LRUCache 阅读全文
posted @ 2021-07-06 13:39 syh-918 阅读(36) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/spiral-matrix/ */public class _54_螺旋矩阵 { public List<Integer> spiralOrder(int[][] matrix) { if (matrix == null) 阅读全文
posted @ 2021-07-06 13:19 syh-918 阅读(37) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof/ */ 环形链表-约瑟夫环public class 面试题_62_圆圈中最后剩下的数字 { // f(n, m) = (f( 阅读全文
posted @ 2021-07-06 11:04 syh-918 阅读(62) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/powx-n/ */public class _50_Pow { // T(n) = T(n/2) + O(1) = O(logn) public double myPow2(double x, int n) { if ( 阅读全文
posted @ 2021-07-06 10:24 syh-918 阅读(76) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/3sum/ */public class _15_三数之和 { public List<List<Integer>> threeSum(int[] nums) { if (nums == null) return null 阅读全文
posted @ 2021-07-06 10:21 syh-918 阅读(36) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/two-sum/ */public class _1_两数之和 { public int[] twoSum(int[] nums, int target) { if (nums == null) return null; 阅读全文
posted @ 2021-07-06 10:18 syh-918 阅读(33) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/permutations-ii/ */public class _47_全排列II { public List<List<Integer>> permuteUnique(int[] nums) { if (nums == 阅读全文
posted @ 2021-07-06 10:16 syh-918 阅读(98) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/permutations/ */public class _46_全排列3 { public List<List<Integer>> permute(int[] nums) { if (nums == null) retu 阅读全文
posted @ 2021-07-06 10:07 syh-918 阅读(29) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/generate-parentheses/ */public class _22_括号生成 { public List<String> generateParenthesis(int n) { List<String> l 阅读全文
posted @ 2021-07-06 10:02 syh-918 阅读(57) 评论(0) 推荐(0)
摘要: /** * https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/ */ 解法二: public class _17_电话号码的字母组合2 { private char[][] lettersArray = { 阅读全文
posted @ 2021-07-06 09:57 syh-918 阅读(121) 评论(0) 推荐(0)