随笔分类 - Level 2
摘要:Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid. The following rules define a valid string: An
阅读全文
摘要:Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus
阅读全文
摘要:Some people will make friend requests. The list of their ages is given and ages[i] is the age of the ith person. Person A will NOT friend request pers
阅读全文
摘要:Given an array of integers nums, calculate the pivot index of this array. The pivot index is the index where the sum of all the numbers strictly to th
阅读全文
摘要:Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing. A subarray is a cont
阅读全文
摘要:Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we tak
阅读全文
摘要:Given the root of a binary tree, find the maximum average value of any subtree of that tree. (A subtree of a tree is any node of that tree plus all it
阅读全文
摘要:第二题 给两个数组,两个数组中的元素都是pair<int, int>,数组表示压缩后的一串数字 A: [(1, 2), (3,1), (2,3), (3, 1)] 表示 {1, 1, 3, 2, 2, 2, 3} B: [(5, 1), (1,1), (3,4), (2, 1)] 表示 {5, 1,
阅读全文
摘要:A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possibl
阅读全文
摘要:第一题一个四位数的密码锁,初始状态为0000, 输入解锁密码,返回最少多少个move可以解开。热身题,考虑几个异常输入即可。 比如说输入 1111, 结果是4输入0000, 结果是0 输入9999, 结果是4 就是算一下每一位input算 Math.Min(input - '0', '9' - in
阅读全文
摘要:From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions). Given two strings source and
阅读全文
摘要:You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.
阅读全文
摘要:Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as "word" contains o
阅读全文
摘要:Given a list of folders, remove all sub-folders in those folders and return in any order the folders after removing. If a folder[i] is located within
阅读全文
摘要:Given a string s and a list of strings dict, you need to add a closed pair of bold tag <b> and </b> to wrap the substrings in s that exist in dict. If
阅读全文
摘要:Create a timebased key-value store class TimeMap, that supports two operations. 1. set(string key, string value, int timestamp) Stores the key and val
阅读全文
摘要:Given two sparse vectors, compute their dot product. Implement class SparseVector: SparseVector(nums) Initializes the object with the vector nums dotP
阅读全文
摘要:(This problem is an interactive problem.) A row-sorted binary matrix means that all elements are 0 or 1 and each row of the matrix is sorted in non-de
阅读全文
摘要:给一个phone pad mapping like: {1,{‘A’,'B' , 'C'}}, {2, { 'D' , 'E' , 'F' }} ... {0, {'X', 'Y', 'Z'}}. 按一次1 返回A,连续两次返回B, 连续四次重新返回A. 输入一组数字,不清楚之间间隔,返回所有可能的
阅读全文
摘要:Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutati
阅读全文

浙公网安备 33010602011771号