随笔分类 - LeetCode
摘要:Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tick
阅读全文
摘要:Given a file and assume that you can only read the file using a given method read4, implement a method read to read n characters. Your method read may
阅读全文
摘要:Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... Example: Input: nums = [3,5,2,1,6,4] Output:
阅读全文
摘要:One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node,
阅读全文
摘要:Given a file and assume that you can only read the file using a given method read4, implement a method to read n characters. Method read4: The API rea
阅读全文
摘要:Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it up
阅读全文
摘要:Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected
阅读全文
摘要:Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be for
阅读全文
摘要:Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined as the sum of the eleme
阅读全文
摘要:Given an m x n integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: le
阅读全文
摘要:Write a program to find the nthsuper ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime listprimesof s...
阅读全文
摘要:Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Example 1: Example 2: Note:You may assume all input has v
阅读全文
摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the...
阅读全文
摘要:Given an integer, write a function to determine if it is a power of three. Example 1: Example 2: Example 3: Example 4: Follow up:Could you do it witho
阅读全文
摘要:You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return
阅读全文
摘要:Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. Th
阅读全文
摘要:There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every t
阅读全文
摘要:Given a string arraywords, find the maximum value oflength(word[i]) * length(word[j])where the two words do not share common letters. You may assume t...
阅读全文
摘要:Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your
阅读全文
摘要:You are given an integer array nums and you have to return a new counts array. The countsarray has the property where counts[i] is the number of small
阅读全文