08 2019 档案
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return the
阅读全文
posted @ 2019-08-25 04:16
fatttcat
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all
阅读全文
posted @ 2019-08-25 03:18
fatttcat
摘要:Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used. Note: Example 1: Example 2:
阅读全文
posted @ 2019-08-24 14:57
fatttcat
摘要:Reverse bits of a given 32 bits unsigned integer. Example 1: Example 2: Note: Note that in some languages such as Java, there is no unsigned integer t
阅读全文
posted @ 2019-08-24 14:03
fatttcat
摘要:Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: Note: You may assume the
阅读全文
posted @ 2019-08-24 13:29
fatttcat
摘要:The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Now your job is to find the total
阅读全文
posted @ 2019-08-24 02:54
fatttcat
摘要:The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calcul
阅读全文
posted @ 2019-08-24 02:33
fatttcat
摘要:Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example 1: Input: 16 Output: true Example 2: Input: 5 Output:
阅读全文
posted @ 2019-08-23 16:14
fatttcat
摘要: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
阅读全文
posted @ 2019-08-23 15:48
fatttcat
摘要:Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the Hamming weight). Example 1: Example 2: Exa
阅读全文
posted @ 2019-08-23 15:36
fatttcat
摘要:Given an integer, write a function to determine if it is a power of two. Example 1: Example 2: Example 3: M1: count how many bits are 1s, if # of 1s =
阅读全文
posted @ 2019-08-23 15:29
fatttcat
摘要: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
阅读全文
posted @ 2019-08-23 13:34
fatttcat
摘要:Given a list of directory info including directory path, and all the files with contents in this directory, you need to find out all the groups of dup
阅读全文
posted @ 2019-08-23 10:38
fatttcat
摘要:Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different integers in that su
阅读全文
posted @ 2019-08-23 08:55
fatttcat
摘要:Given a binary array data, return the minimum number of swaps required to group all 1’s present in the array together in any placein the array. Exampl
阅读全文
posted @ 2019-08-23 06:37
fatttcat
摘要:Given a string s that consists of only uppercase English letters, you can perform at most k operations on that string. In one operation, you can choos
阅读全文
posted @ 2019-08-21 12:53
fatttcat
摘要:Given a string S, return the number of substrings of length K with no repeated characters. Example 1: Example 2: Note: sliding window 1. first store t
阅读全文
posted @ 2019-08-21 09:15
fatttcat
摘要:Given two strings s1 and s2, write a function to return true if s2contains the permutation of s1. In other words, one of the first string's permutatio
阅读全文
posted @ 2019-08-21 08:51
fatttcat
摘要:Given an array A of 0s and 1s, we may change up to K values from 0 to 1. Return the length of the longest (contiguous) subarray that contains only 1s.
阅读全文
posted @ 2019-08-19 04:22
fatttcat
摘要:Given a binary array, find the maximum number of consecutive 1s in this array if you can flip at most one 0. Example 1: Note: The input array will onl
阅读全文
posted @ 2019-08-17 15:50
fatttcat
摘要:Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: The input array will only contain 0 and 1. The length
阅读全文
posted @ 2019-08-17 15:33
fatttcat
摘要:Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list
阅读全文
posted @ 2019-08-16 15:45
fatttcat
摘要:You have a list of words and a pattern, and you want to know which words in words matches the pattern. A word matches the pattern if there exists a pe
阅读全文
posted @ 2019-08-15 15:40
fatttcat
摘要:To some string S, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size). Each repla
阅读全文
posted @ 2019-08-15 15:16
fatttcat
摘要:We are given two strings, A and B. A shift on A consists of taking string A and moving the leftmost character to the rightmost position. For example,
阅读全文
posted @ 2019-08-15 07:11
fatttcat
摘要:Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positi
阅读全文
posted @ 2019-08-12 15:53
fatttcat
摘要:Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. E
阅读全文
posted @ 2019-08-12 15:36
fatttcat
摘要:Given an input string , reverse the string word by word. Example: Input: ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"] Output: [&
阅读全文
posted @ 2019-08-12 15:20
fatttcat
摘要:Given an input string, reverse the string word by word. Example 1: Example 2: Example 3: Note: A word is defined as a sequence of non-space characters
阅读全文
posted @ 2019-08-12 15:08
fatttcat
摘要:Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Example 2: Input: "leetcode" Output: "leotcede" Exam
阅读全文
posted @ 2019-08-12 12:07
fatttcat
摘要:Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there ar
阅读全文
posted @ 2019-08-11 15:09
fatttcat
摘要:Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them. We repeatedly make
阅读全文
posted @ 2019-08-11 14:40
fatttcat
摘要:Given a list of dominoes, dominoes[i] = [a, b] is equivalentto dominoes[j] = [c, d] if and only if either (a==c and b==d), or (a==d and b==c) - that i
阅读全文
posted @ 2019-08-11 14:39
fatttcat
摘要:Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. Example: use queue to keep track of
阅读全文
posted @ 2019-08-11 14:17
fatttcat
摘要:Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the
阅读全文
posted @ 2019-08-10 16:20
fatttcat
摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr
阅读全文
posted @ 2019-08-10 16:01
fatttcat
摘要:Given a sorted array nums, remove the duplicates in-placesuch that duplicates appeared at most twice and return the new length. Do not allocate extra
阅读全文
posted @ 2019-08-10 13:50
fatttcat
摘要:Given a string S, remove the vowels 'a', 'e', 'i', 'o', and 'u' from it, and return the new string. Example 1: Example 2: Note:
阅读全文
posted @ 2019-08-10 12:30
fatttcat
摘要:Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another ar
阅读全文
posted @ 2019-08-10 08:48
fatttcat
摘要:Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond
阅读全文
posted @ 2019-08-10 08:36
fatttcat
摘要:Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including d
阅读全文
posted @ 2019-08-10 08:07
fatttcat
摘要:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to le
阅读全文
posted @ 2019-08-08 09:48
fatttcat
摘要:Numbers can be regarded as product of its factors. For example, Write a function that takes an integer n and return all possible combinations of its f
阅读全文
posted @ 2019-08-08 09:33
fatttcat
摘要:Given two integers n and k, return all possible combinations of knumbers out of 1 ... n. Example: use DFS (backtracking) time = O(k * C(n, k)), space
阅读全文
posted @ 2019-08-07 08:43
fatttcat
浙公网安备 33010602011771号