随笔分类 -  Level 2

上一页 1 2 3 4 5 6 7 ··· 12 下一页
摘要:Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1, and return them in any ord 阅读全文
posted @ 2020-12-27 02:45 北叶青藤 阅读(103) 评论(0) 推荐(0)
摘要:Given an array of positive integers arr (not necessarily distinct), return the lexicographically largest permutation that is smaller than arr, that ca 阅读全文
posted @ 2020-12-27 01:47 北叶青藤 阅读(128) 评论(0) 推荐(0)
摘要:You are given some lists of regions where the first region of each list includes all other regions in that list. Naturally, if a region X contains ano 阅读全文
posted @ 2020-12-27 00:54 北叶青藤 阅读(118) 评论(0) 推荐(0)
摘要:Problem description: Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the 阅读全文
posted @ 2020-12-16 07:47 北叶青藤 阅读(102) 评论(0) 推荐(0)
摘要:Given a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements a 阅读全文
posted @ 2020-12-14 14:05 北叶青藤 阅读(121) 评论(0) 推荐(0)
摘要:Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: Input: [0,1] Output: 2 Explanation: [0 阅读全文
posted @ 2020-12-02 14:10 北叶青藤 阅读(74) 评论(0) 推荐(0)
摘要:Given the root of a binary tree, find the maximum value V for which there exists different nodes A and B where V = |A.val - B.val| and A is an ancesto 阅读全文
posted @ 2020-04-05 10:46 北叶青藤 阅读(268) 评论(0) 推荐(0)
摘要:Let's call an array A a mountain if the following properties hold: A.length >= 3 There exists some 0 < i < A.length - 1 such that A[0] < A[1] < ... A[ 阅读全文
posted @ 2020-03-13 15:22 北叶青藤 阅读(176) 评论(0) 推荐(0)
摘要:There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct 阅读全文
posted @ 2020-03-11 12:18 北叶青藤 阅读(274) 评论(0) 推荐(0)
摘要:Given a rooted binary tree, return the lowest common ancestor of its deepest leaves. Recall that: The node of a binary tree is a leaf if and only if i 阅读全文
posted @ 2020-03-07 15:07 北叶青藤 阅读(173) 评论(0) 推荐(0)
摘要:You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1' 阅读全文
posted @ 2020-03-03 15:40 北叶青藤 阅读(198) 评论(0) 推荐(0)
摘要:Given a string s and an integer k, find out if the given string is a K-Palindrome or not. A string is K-Palindrome if it can be transformed into a pal 阅读全文
posted @ 2020-02-08 00:04 北叶青藤 阅读(294) 评论(0) 推荐(0)
摘要:Given a matrix, like this[[0, 0, 1, 1, 1][0, 1, 1, 1, 1][0, 0, 1, 1, 1][0, 0, 0, 0, 0]]each cell is either 1 or 0in each row, from left to right, when 阅读全文
posted @ 2020-02-07 11:18 北叶青藤 阅读(178) 评论(0) 推荐(0)
摘要:给两个bst,把它们的值按照从小到大打印。 1 public static void print2BSTInorder(TreeNode n1, TreeNode n2, List<Integer> result) { 2 Stack<TreeNode> stack1 = new Stack<>() 阅读全文
posted @ 2020-02-07 07:02 北叶青藤 阅读(97) 评论(0) 推荐(0)
摘要:byte swap一个 32位数 0x12345678 --> 0x78563412先是用了俩高低位mask 两两交换,不满意。然后用了一个mask,每次取一个byte,移位异或ans。一共执行四次,还是不满意。提示说用两步,能不能先交换 LSB 和 MSB,写了一下,但还是想不出怎么写。。。正解: 阅读全文
posted @ 2020-02-07 03:49 北叶青藤 阅读(765) 评论(0) 推荐(0)
摘要:Given a string s of '(' , ')' and lowercase English characters. Your task is to remove the minimum number of parentheses ( '(' or ')', in any position 阅读全文
posted @ 2020-02-06 13:46 北叶青藤 阅读(170) 评论(0) 推荐(0)
摘要:给两个已经排序好的数组A,B,和一个常数k, 找i,j使得 Ai + Bj - k 的绝对值最小 分析: Two pointer, i从A从前往后扫,j从B从后往前扫.if (A[i]+B[j] > k){ j--;}else { i++;}整个过程不断更新答案 阅读全文
posted @ 2020-02-06 12:04 北叶青藤 阅读(150) 评论(0) 推荐(0)
摘要:有个N叉树是个大食堂的地图。节点有的是餐馆,有的不是,在输入里面用boolean表示了。每个父节点到子节点的距离都是一。你作为一个吃货,从根节点出发,要去所有的餐馆尝尝,需要的最短路径是多少。楼主DFS返回两个量,一个是这个节点为根的树要吃完需要的走多长的路,另一个是一个flag表示这个子树里面有没 阅读全文
posted @ 2020-02-06 06:22 北叶青藤 阅读(185) 评论(0) 推荐(0)
摘要:Given a binary tree rooted at root, the depth of each node is the shortest distance to the root. A node is deepest if it has the largest depth possibl 阅读全文
posted @ 2020-02-06 06:11 北叶青藤 阅读(113) 评论(0) 推荐(0)
摘要:Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. Example: Input: 阅读全文
posted @ 2020-02-06 05:45 北叶青藤 阅读(112) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 ··· 12 下一页