leetcode讲解--693. Binary Number with Alternating Bits

2019-01-07
阅读 2 分钟
1.5k
Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.

leetcode讲解--937. Reorder Log Files

2019-01-04
阅读 3 分钟
3k
You have an array of logs. Each log is a space delimited string of words.

leetcode讲解--739. Daily Temperatures

2019-01-04
阅读 1 分钟
1.9k
Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.

leetcode讲解--496. Next Greater Element I

2019-01-02
阅读 2 分钟
1.4k
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2.

leetcode讲解--575. Distribute Candies

2019-01-02
阅读 2 分钟
1.3k
Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these candies equally in number to brother and sister. Return the maximum number of kinds of candies t...

leetcode讲解--868. Binary Gap

2019-01-01
阅读 2 分钟
1.3k
Given a positive integer N, find and return the longest distance between two consecutive 1's in the binary representation of N.

leetcode讲解--682. Baseball Game

2019-01-01
阅读 3 分钟
1.1k
Given a list of strings, each string can be one of the 4 following types:

leetcode讲解--893. Groups of Special-Equivalent Strings

2018-12-30
阅读 2 分钟
1.7k
Two strings S and T are special-equivalent if after any number of moves, S == T.

leetcode讲解--821. Shortest Distance to a Character

2018-12-29
阅读 2 分钟
1.6k
Given a string S and a character C, return an array of integers representing the shortest distance from the character C in the string.

leetcode讲解--806. Number of Lines To Write String

2018-12-28
阅读 2 分钟
1.4k
We are to write the letters of a given string S, from left to right into lines. Each line has maximum width 100 units, and if writing a letter would cause the width of the line to exceed 100 units, it is written on the next line. We are given an array widths, an array where widths[0] is the width...

leetcode讲解--908. Smallest Range I

2018-12-26
阅读 2 分钟
1.7k
Given an array A of integers, for each integer A[i] we may choose any x with -K <= x <= K, and add x to A[i].

leetcode讲解--883. Projection Area of 3D Shapes

2018-12-26
阅读 2 分钟
1.7k
On a N * N grid, we place some 1 * 1 * 1 cubes that are axis-aligned with the x, y, and z axes.

leetcode讲解--961. N-Repeated Element in Size 2N Array

2018-12-26
阅读 1 分钟
2.2k
In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times.

leetcode讲解--922. Sort Array By Parity II

2018-12-25
阅读 1 分钟
2.1k
Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even.

leetcode讲解--763. Partition Labels

2018-12-25
阅读 2 分钟
2.3k
A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.

leetcode讲解--561. Array Partition I

2018-12-24
阅读 1 分钟
1.5k
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say $(a_1, b_1), (a_2, b_2), \cdots, (a_n, b_n)$ which makes sum of $min(a_i, b_i)$ for all i from 1 to n as large as possible.

leetcode讲解--852. Peak Index in a Mountain Array

2018-12-19
阅读 1 分钟
1.4k
A.length >= 3There exists some 0 < i < A.length - 1 such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1]Given an array that is definitely a mountain, return any i such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.leng...