摘要: Given the root of a binary tree, find the maximum value V for which there exist different nodes A and B where V = |A.val - B.val| and A is an ancestor 阅读全文
posted @ 2020-11-11 17:11 fatttcat 阅读(119) 评论(0) 推荐(0)
摘要: ... M1: sort + two pointersPush from the two ends and attempt to find any addition of the two elements < K;if the addition >= K, then decrease the hig 阅读全文
posted @ 2020-11-11 17:06 fatttcat 阅读(130) 评论(0) 推荐(0)
摘要: A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles i 阅读全文
posted @ 2020-11-11 16:59 fatttcat 阅读(156) 评论(0) 推荐(0)
摘要: ... M1: time = O(nlogn), space = O(logn) for sorting class Solution { public boolean canAttendMeetings(int[][] intervals) { Arrays.sort(intervals, (a, 阅读全文
posted @ 2020-11-11 16:52 fatttcat 阅读(83) 评论(0) 推荐(0)
摘要: You are given the root of a binary search tree (BST), where exactly two nodes of the tree were swapped by mistake. Recover the tree without changing i 阅读全文
posted @ 2020-11-11 16:48 fatttcat 阅读(119) 评论(0) 推荐(0)
摘要: Given an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing. Example 1: 阅读全文
posted @ 2020-11-11 16:43 fatttcat 阅读(116) 评论(0) 推荐(0)
摘要: You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that th 阅读全文
posted @ 2020-11-11 16:41 fatttcat 阅读(187) 评论(0) 推荐(0)