自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 收藏
  • 关注

原创 2021-01-28

class Solution { public boolean isPowerOfTwo(int n) { if (n == 0) return false; while (n % 2 == 0) n /= 2; return n == 1; } } class Solution { public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { List&lt

2021-01-28 01:18:29 115

原创 2021-01-26

class Solution { public boolean isPowerOfTwo(int n) { if (n == 0) return false; while (n % 2 == 0) n /= 2; return n == 1; } } class Solution { public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { List&lt

2021-01-26 21:18:45 76

原创 2021-01-25

class Solution { Random random = new Random(); public int findKthLargest(int[] nums, int k) { return quickSelect(nums, 0, nums.length - 1, nums.length - k); } public int quickSelect(int[] a, int l, int r, int index) { int

2021-01-25 16:30:06 76

原创 2021-01-23

class LRUCache extends LinkedHashMap<Integer, Integer>{ private int capacity; public LRUCache(int capacity) { super(capacity, 0.75F, true); this.capacity = capacity; } public int get(int key) { return sup

2021-01-23 23:54:50 61

原创 2021-01-23

class Solution { public int singleNumber(int[] nums) { Map<Integer, Integer> hm = new HashMap<Integer, Integer>(); for (int i = 0; i < nums.length; i++) { if (!hm.containsKey(nums[i])) { hm.put(nums[i], 1); }

2021-01-23 00:01:48 54

原创 2021-01-21

class Solution { int maxSum = Integer.MIN_VALUE; public int maxPathSum(TreeNode root) { maxGain(root); return maxSum; } public int maxGain(TreeNode node) { if (node == null) { return 0; }

2021-01-21 20:39:34 52

原创 2021-01-20

class Solution { public void merge(int[] nums1, int m, int[] nums2, int n) { int i = m - 1, j = n - 1, k = m + n - 1; while (i >= 0 && j >= 0) { if (nums1[i] > nums2[j]) { nums1[k--] = nums1[i]; --i; } .

2021-01-20 21:20:36 55

原创 2021-01-19

class Solution { public int uniquePaths(int m, int n) { int[][] f = new int[m][n]; for (int i = 0; i < m; ++i) { f[i][0] = 1; } for (int j = 0; j < n; ++j) { f[0][j] = 1; } f

2021-01-19 20:10:53 45

原创 2021-01-19

class Solution { public List<Integer> spiralOrder(int[][] matrix) { List<Integer> order = new ArrayList<Integer>(); if (matrix == null || matrix.length == 0 || matrix[0].length == 0) { return order;

2021-01-19 02:20:33 104

原创 2021-01-18

// max保存的是全局最大子序列和,pre保存的是包含nums[n-1]的n-1序列最大连续子序列 int max = nums[0]; int pre = 0; for (int i = 1; i < nums.length; i++) { // 先对pre做维护 if (nums[i] + pre >= nums[i])// 其实就是前面是个正数 { pre = nums[i] + pre; } ...

2021-01-18 02:34:29 100

原创 2021-01-17

class Solution { public ListNode mergeKLists(ListNode[] lists) { return merge(lists, 0, lists.length - 1); } public ListNode merge(ListNode[] lists, int l, int r) { if (l == r) { return lists[l]; } i

2021-01-17 01:50:14 78

原创 2021-01-15

class Solution { public int threeSumClosest(int[] nums, int target) { Arrays.sort(nums); int n = nums.length; int best = 10000000; // 枚举 a for (int i = 0; i < n; ++i) { // 保证和上一次枚举的元素不相等

2021-01-15 23:27:49 56

原创 2021-01-14

class Solution { public String longestCommonPrefix(String[] strs) { if (strs == null || strs.length == 0) { return ""; } String prefix = strs[0]; int count = strs.length; for (int i = 1; i < count;

2021-01-14 02:08:12 56

原创 2021-01-13

class Solution { public int myAtoi(String str) { Automaton automaton = new Automaton(); int length = str.length(); for (int i = 0; i < length; ++i) { automaton.get(str.charAt(i)); } return (int) (a

2021-01-13 00:19:55 59

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除