04 2020 档案
摘要:Given two integers a and b, return the sum of the two integers without using the operators + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2
阅读全文
摘要:You have a queue of integers, you need to retrieve the first unique integer in the queue. Implement the FirstUnique class: FirstUnique(int[] nums) Ini
阅读全文
摘要:(This problem is an interactive problem.) You may recall that an array arr is a mountain array if and only if: arr.length >= 3 There exists some i wit
阅读全文
摘要:Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists
阅读全文
摘要:Let's call an array arr a mountain if the following properties hold: arr.length >= 3 There exists some i with 0 < i < arr.length - 1 such that: arr[0]
阅读全文
摘要:Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example 1: Input: matrix = [["1
阅读全文
摘要:Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements tha
阅读全文
摘要:Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array. A k-diff pair is an integer pair (nums[i], nu
阅读全文
摘要:Given alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits). You have to find a permutation of t
阅读全文
摘要:You are given an array of CPU tasks, each represented by letters A to Z, and a cooling time, n. Each cycle or interval allows the completion of one ta
阅读全文
摘要:Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that: 0 <= i, j, k, l < n nums
阅读全文
摘要:Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a, b, c, d < n a
阅读全文
摘要:Given a non-negative integer represented as a linked list of digits, plus one to the integer. The digits are stored such that the most significant dig
阅读全文
摘要:Design a data structure that supports all following operations in average O(1) time. insert(val): Inserts an item val to the set if not already presen
阅读全文
摘要:On a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square represented by 0. A move consists of choosing 0 and a 4
阅读全文
摘要:(This problem is an interactive problem.) A binary matrix means that all elements are 0 or 1. For each individual row of the matrix, this row is sorte
阅读全文
摘要:Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The r
阅读全文
摘要:Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length. Do not allocate extra s
阅读全文
摘要:Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the sa
阅读全文
摘要:Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it. Return the number of nice sub
阅读全文
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9
阅读全文
摘要:Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the dig
阅读全文
摘要:Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kth smallest element in the matrix. Note that it is
阅读全文
摘要:There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with
阅读全文
摘要:You are given an image represented by an m x n grid of integers image, where image[i][j] represents the pixel value of the image. You are also given t
阅读全文
摘要:You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may
阅读全文
摘要:You are given an m x n grid where each cell can have one of three values: 0 representing an empty cell, 1 representing a fresh orange, or 2 representi
阅读全文
摘要:Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Note: The number o
阅读全文
摘要:You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [direction, amount]: direction can be 0 (for left
阅读全文
摘要:Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subs
阅读全文
摘要:Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Retu
阅读全文
摘要:Given an integer array nums and an integer k, return true if nums has a good subarray or false otherwise. A good subarray is a subarray where: its len
阅读全文
摘要:Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. A subarray is a contiguous non-empty seq
阅读全文
摘要:Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1. Example 1: Input: nums = [0,1] Output:
阅读全文
摘要:You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choo
阅读全文
摘要:Given a string s and an integer k, rearrange s such that the same characters are at least distance k from each other. If it is not possible to rearran
阅读全文
摘要:Given a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any possible rearrangement of s or return
阅读全文
摘要: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
阅读全文
摘要:Design a logger system that receives a stream of messages along with their timestamps. Each unique message should only be printed at most every 10 sec
阅读全文
摘要:Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list. k is a positive integer and is less than or
阅读全文
摘要:Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i
阅读全文
摘要:We are given a list schedule of employees, which represents the working time for each employee. Each employee has a list of non-overlapping Intervals,
阅读全文
摘要:Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] +
阅读全文
摘要:Given a string s, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can f
阅读全文
摘要:Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after
阅读全文
摘要:Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer
阅读全文
摘要:There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you. You are given a list of strings
阅读全文
摘要:Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by wa
阅读全文
摘要:Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations
阅读全文
摘要:Design and implement a data structure for a Least Frequently Used (LFU) cache. Implement the LFUCache class: LFUCache(int capacity) Initializes the ob
阅读全文
摘要:Given the availability time slots arrays slots1 and slots2 of two people and a meeting duration duration, return the earliest time slot that works for
阅读全文
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1: Input: n = 3 Output: ["((()))","(()
阅读全文
摘要:You are given a string s and an array of strings words of the same length. Return all starting indices of substring(s) in s that is a concatenation of
阅读全文
摘要:Given an integer array nums and an integer k, return the number of good subarrays of nums. A good array is an array where the number of different inte
阅读全文
摘要:You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can
阅读全文
摘要:Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to
阅读全文
摘要:Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order. An Anagram is a word
阅读全文
摘要:Given a string s, return the length of the longest substring that contains at most two distinct characters. Example 1: Input: s = "eceba" Output: 3 Ex
阅读全文
摘要:Given a string s and an integer k, return the length of the longest substring of s that contains at most k distinct characters. Example 1: Input: s =
阅读全文
摘要:Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The a
阅读全文
摘要:Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicat
阅读全文
摘要:最小窗口子串。题意是给两个字符串S和T,T比较短。请输出一个最小的S的子串,包含了T中出现的所有字母。例子, Example: Input: S = "ADOBECODEBANC", T = "ABC" Output: "BANC" 这个题因为有时间复杂度的要求所以只能用到一个叫做滑动窗口的思想。在
阅读全文
摘要:Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it.
阅读全文
摘要:Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linea
阅读全文
摘要: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
阅读全文
摘要:You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots. Given an int
阅读全文
摘要:A string is a valid parentheses string (denoted VPS) if and only if it consists of "(" and ")" characters only, and: It is the empty string, or It can
阅读全文
摘要:Given an m x n matrix board where each cell is a battleship 'X' or empty '.', return the number of the battleships on board. Battleships can only be p
阅读全文

浙公网安备 33010602011771号