Quantcast
Channel: 书影 - Entries for the tag leetcode
Browsing all 559 articles
Browse latest View live

[LeetCode]Remove Duplicate Letters

题目描述: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 result is the smallest in lexicographical...

View Article


[LeetCode]Maximum Product of Word Lengths

题目描述:Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case...

View Article


[LeetCode]Bulb Switcher

题目描述: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 third bulb (turning on if it's off or turning...

View Article

[LeetCode]Create Maximum Number

题目描述: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. The relative order of the digits from the...

View Article

[LeetCode]Coin Change

题目描述:You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of...

View Article


[LeetCode]Wiggle Sort II

题目描述:Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....Example: (1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5, 1, 6]. (2)...

View Article

[LeetCode]Sum Root to Leaf Numbers

题目描述:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the...

View Article

[LeetCode]Power of Three

题目描述:Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop /...

View Article


[LeetCode]Count of Range Sum

题目描述: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 elements in nums between indices i and j (i≤ j),...

View Article


[LeetCode]Odd Even Linked List

题目描述: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 value in the nodes.You should try to do it in...

View Article

[LeetCode]Longest Increasing Path in a Matrix

题目描述:Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside...

View Article

[LeetCode]String to Integer (atoi)

题目描述:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input...

View Article

[LeetCode]Patching Array

题目描述: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 formed by the sum of some elements in the array....

View Article


[LeetCode]Verify Preorder Serialization of a Binary Tree

题目描述:One way to serialize a binary tree is to use pre-oder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #....

View Article

[LeetCode]Reconstruct Itinerary

题目描述:Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK....

View Article


[LeetCode]Increasing Triplet Subsequence

题目描述:Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if there exists i, j, k such that arr[i]<...

View Article

[LeetCode]Self Crossing

题目描述:LeetCode 335. Self CrossingYou are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west, x[2] metres to the south, x[3]...

View Article


[LeetCode]Palindrome Pairs

题目描述:LeetCode 336. Palindrome PairsGiven a list of unique words. Find all pairs of indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a...

View Article

[LeetCode]House Robber III

题目描述:LeetCode 337. House Robber IIIThe thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and...

View Article

[LeetCode]Counting Bits

题目描述:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5 you...

View Article
Browsing all 559 articles
Browse latest View live