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 阅读全文
posted @ 2020-04-30 12:44 CNoodle 阅读(172) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-30 07:31 CNoodle 阅读(1548) 评论(0) 推荐(0)
摘要:(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 阅读全文
posted @ 2020-04-29 08:54 CNoodle 阅读(250) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-29 08:43 CNoodle 阅读(191) 评论(0) 推荐(0)
摘要: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] 阅读全文
posted @ 2020-04-29 04:29 CNoodle 阅读(186) 评论(0) 推荐(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 阅读全文
posted @ 2020-04-28 13:41 CNoodle 阅读(258) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-28 12:43 CNoodle 阅读(166) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-27 06:44 CNoodle 阅读(211) 评论(0) 推荐(0)
摘要:Given alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits). You have to find a permutation of t 阅读全文
posted @ 2020-04-26 16:24 CNoodle 阅读(410) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-26 13:16 CNoodle 阅读(448) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-26 07:30 CNoodle 阅读(139) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-26 05:37 CNoodle 阅读(491) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-25 06:09 CNoodle 阅读(428) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-24 06:39 CNoodle 阅读(229) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-24 02:18 CNoodle 阅读(311) 评论(0) 推荐(0)
摘要:(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 阅读全文
posted @ 2020-04-23 10:52 CNoodle 阅读(1772) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-22 01:13 CNoodle 阅读(464) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-22 00:39 CNoodle 阅读(450) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-21 12:13 CNoodle 阅读(715) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-21 07:58 CNoodle 阅读(923) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-20 06:39 CNoodle 阅读(467) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-20 06:21 CNoodle 阅读(478) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-19 06:34 CNoodle 阅读(251) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-17 06:02 CNoodle 阅读(231) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-17 02:44 CNoodle 阅读(162) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-16 14:29 CNoodle 阅读(259) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-16 13:13 CNoodle 阅读(243) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-16 12:07 CNoodle 阅读(235) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-16 05:52 CNoodle 阅读(580) 评论(0) 推荐(0)
摘要:Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subs 阅读全文
posted @ 2020-04-16 03:03 CNoodle 阅读(429) 评论(0) 推荐(0)
摘要:Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Retu 阅读全文
posted @ 2020-04-16 02:40 CNoodle 阅读(441) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-15 03:29 CNoodle 阅读(212) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-14 12:28 CNoodle 阅读(397) 评论(0) 推荐(0)
摘要: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: 阅读全文
posted @ 2020-04-14 10:12 CNoodle 阅读(237) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-14 08:38 CNoodle 阅读(139) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-14 08:13 CNoodle 阅读(799) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-14 06:40 CNoodle 阅读(289) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-14 04:11 CNoodle 阅读(351) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-14 02:01 CNoodle 阅读(190) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-13 07:09 CNoodle 阅读(516) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-12 13:41 CNoodle 阅读(485) 评论(0) 推荐(0)
摘要: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, 阅读全文
posted @ 2020-04-10 14:27 CNoodle 阅读(720) 评论(0) 推荐(1)
摘要: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] + 阅读全文
posted @ 2020-04-10 06:43 CNoodle 阅读(198) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-10 05:12 CNoodle 阅读(168) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-10 01:46 CNoodle 阅读(205) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-09 13:59 CNoodle 阅读(544) 评论(0) 推荐(0)
摘要: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  阅读全文
posted @ 2020-04-08 06:21 CNoodle 阅读(616) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-07 13:05 CNoodle 阅读(261) 评论(0) 推荐(0)
摘要:Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations 阅读全文
posted @ 2020-04-07 00:49 CNoodle 阅读(504) 评论(0) 推荐(0)
摘要:Design and implement a data structure for a Least Frequently Used (LFU) cache. Implement the LFUCache class: LFUCache(int capacity) Initializes the ob 阅读全文
posted @ 2020-04-06 09:01 CNoodle 阅读(291) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-05 06:54 CNoodle 阅读(1341) 评论(0) 推荐(0)
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1: Input: n = 3 Output: ["((()))","(() 阅读全文
posted @ 2020-04-04 14:47 CNoodle 阅读(447) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-04 08:01 CNoodle 阅读(439) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-04 06:06 CNoodle 阅读(504) 评论(0) 推荐(1)
摘要: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 阅读全文
posted @ 2020-04-04 01:21 CNoodle 阅读(217) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-03 15:51 CNoodle 阅读(214) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-03 14:57 CNoodle 阅读(260) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-03 10:03 CNoodle 阅读(353) 评论(0) 推荐(0)
摘要: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 = 阅读全文
posted @ 2020-04-03 09:48 CNoodle 阅读(244) 评论(0) 推荐(0)
摘要:Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The a 阅读全文
posted @ 2020-04-03 08:29 CNoodle 阅读(493) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-03 07:02 CNoodle 阅读(616) 评论(0) 推荐(0)
摘要:最小窗口子串。题意是给两个字符串S和T,T比较短。请输出一个最小的S的子串,包含了T中出现的所有字母。例子, Example: Input: S = "ADOBECODEBANC", T = "ABC" Output: "BANC" 这个题因为有时间复杂度的要求所以只能用到一个叫做滑动窗口的思想。在 阅读全文
posted @ 2020-04-03 06:23 CNoodle 阅读(154) 评论(0) 推荐(0)
摘要: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. 阅读全文
posted @ 2020-04-02 01:47 CNoodle 阅读(454) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-02 01:35 CNoodle 阅读(496) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-01 13:39 CNoodle 阅读(271) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-01 05:25 CNoodle 阅读(177) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-01 02:34 CNoodle 阅读(396) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2020-04-01 01:32 CNoodle 阅读(179) 评论(0) 推荐(0)