随笔分类 - LeetCode
摘要:You are given two jugs with capacities jug1Capacity and jug2Capacity liters. There is an infinite amount of water supply available. Determine whether
阅读全文
摘要:Assume you have an array of length n initialized with all 0's and are given k update operations. Each operation is represented as a triplet: [startInd
阅读全文
摘要:Given a non-negative integer represented as non-empty a singly linked list of digits, plus one to the integer. You may assume the integer do not conta
阅读全文
摘要:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or
阅读全文
摘要:Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library functio
阅读全文
摘要:Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k. Example: Inp
阅读全文
摘要:Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty. Example: Input:
阅读全文
摘要:Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- w
阅读全文
摘要:Design a hit counter which counts the number of hits received in the past 5 minutes. Each function accepts a timestamp parameter (in seconds granulari
阅读全文
摘要:Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can kill using one bomb.
阅读全文
摘要:Given a sorted array of integers nums and integer values a, band c. Apply a quadratic function of the form f(x) = ax2 + bx + c to each element x in th
阅读全文
摘要:Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not printed in t
阅读全文
摘要:Given a non-empty string s and an integer k, rearrange the string such that the same characters are at least distance k from each other. All input str
阅读全文
摘要:Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Given n = 2, return 91. (The answer should be the
阅读全文
摘要:Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points. Example 1: Input: [[1,1],[-1,1]] Output:
阅读全文
摘要:Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the
阅读全文
摘要:You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the w
阅读全文
摘要:Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game. The snak
阅读全文
摘要:Given a data stream input of non-negative integers a1, a2, ..., an, ..., summarize the numbers seen so far as a list of disjoint intervals. For exampl
阅读全文
摘要:Given an Android 3x3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, count the total number of unlock patterns of the Android lock scre
阅读全文

浙公网安备 33010602011771号