随笔分类 -  Data Structures

摘要:Given preorder and inorder traversal of a tree, construct the binary tree. You may assume that duplicates do not exist in the tree. Example Given in-o 阅读全文
posted @ 2020-05-28 02:25 Review->Improve 阅读(390) 评论(0) 推荐(0)
摘要:Return the lexicographically smallest subsequence of text that contains all the distinct characters of text exactly once. Example 1: Input: "cdadabcc" 阅读全文
posted @ 2020-05-27 12:20 Review->Improve 阅读(306) 评论(0) 推荐(0)
摘要:Given many words, words[i] has weight i. Design a class WordFilter that supports one function, WordFilter.f(String prefix, String suffix). It will ret 阅读全文
posted @ 2020-05-27 06:54 Review->Improve 阅读(300) 评论(0) 推荐(0)
摘要:Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks coul 阅读全文
posted @ 2020-05-27 03:13 Review->Improve 阅读(259) 评论(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-05-26 22:23 Review->Improve 阅读(291) 评论(0) 推荐(0)
摘要:Given an array of integers and a number k, the majority number is the number that occurs more than 1/k of the size of the array, find all the majority 阅读全文
posted @ 2020-05-22 06:29 Review->Improve 阅读(189) 评论(0) 推荐(0)
摘要:Problem Link: Multiple of 2019 Key idea: For subarray S[i1, j] and S[i2, j] with i1 < i2, if the V[i1, j] % 2019 is the same with V[i2, k] % 2019, it 阅读全文
posted @ 2020-05-13 05:18 Review->Improve 阅读(217) 评论(0) 推荐(0)
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 阅读全文
posted @ 2020-05-08 09:41 Review->Improve 阅读(142) 评论(0) 推荐(0)
摘要:You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing order. You are allowed to choose exactly 1 element f 阅读全文
posted @ 2020-05-05 05:32 Review->Improve 阅读(637) 评论(0) 推荐(0)
摘要:Given an array of n integer with duplicate number, and a moving window(size k), move the window at each iteration from the start of the array, find th 阅读全文
posted @ 2020-05-05 02:47 Review->Improve 阅读(538) 评论(0) 推荐(0)
摘要:Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the vali 阅读全文
posted @ 2020-04-17 23:53 Review->Improve 阅读(228) 评论(0) 推荐(0)
摘要:You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from th 阅读全文
posted @ 2020-04-15 03:00 Review->Improve 阅读(405) 评论(0) 推荐(0)
摘要:Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it is th 阅读全文
posted @ 2020-04-15 01:57 Review->Improve 阅读(309) 评论(0) 推荐(0)
摘要:Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the fol 阅读全文
posted @ 2020-04-14 08:04 Review->Improve 阅读(719) 评论(0) 推荐(0)
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov 阅读全文
posted @ 2020-04-10 22:34 Review->Improve 阅读(128) 评论(0) 推荐(0)
摘要:There are n soldiers standing in a line. Each soldier is assigned a unique rating value. You have to form a team of 3 soldiers amongst them under the 阅读全文
posted @ 2020-04-02 12:52 Review->Improve 阅读(2351) 评论(0) 推荐(0)
摘要:Given a m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i] 阅读全文
posted @ 2020-03-02 08:23 Review->Improve 阅读(1029) 评论(0) 推荐(0)
摘要:Problem Statement Link Clarification: The problem states that for each pair of points, we consider the minimum possible distance over any possible mom 阅读全文
posted @ 2020-02-28 23:07 Review->Improve 阅读(362) 评论(0) 推荐(0)
摘要:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two 阅读全文
posted @ 2019-12-09 08:40 Review->Improve 阅读(1372) 评论(2) 推荐(1)
摘要:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two 阅读全文
posted @ 2019-12-09 08:23 Review->Improve 阅读(441) 评论(0) 推荐(0)