分类: 算法

记录点滴,修炼自己。
0

leetcode [#409]

题目 Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example “Aa” is not con

0

leetcode [#414]

题目 Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). Example1:Input: [3, 2, 1]

0

leetcode [#415]

题目 Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < 5100. Both num1 and num2 contains only digits 0

0

leetcode [#400]

题目 Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, … Example1:Input:3 Output:3 Example2:Input:11 Output:0 Explanation:The 11th digit of the sequence 1, 2, 3, 4,

0

leetcode [#396]

题目 Given an array of integers A and let n to be its length. Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a “rotation function” F on A as follow: F(k) =

0

leetcode [#394]

题目 Given an encoded string, return it’s decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is

0

leetcode [#383]

题目 Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines

0

leetcode [#389]

题目 Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter that was ad

0

leetcode [#374]

题目 We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I’ll tell you whether the number is higher

0

leetcode [#36]

题目 解决方案12 注意事项 以下方法是错误的:12345678910111213141516171819202122import java.util.HashSet;public class Solution { public boolean isValidSudoku(char[][] board) { for(int i = 0; i <

0

leetcode [#38]

题目 The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, … 1 is read off as “one 1” or 11.11 is read off as “two 1s” or 21.21 is read off as “one 2, the

0

leetcode [#350]

题目 Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each element in the result should appear as many times a

0

leetcode [#35]

题目 Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array

0

leetcode [#349]

题目 Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element in the result must be unique. The result can b

0

leetcode [#344]

题目 Write a function that takes a string as input and reverse only the vowels of a string. Example:Given s = “hello”, return “holle”.Given s = “leetcode”, return “leotcede”. Note:The vowels does not i

0

leetcode [#344]

题目 Write a function that takes a string as input and returns the string reversed. Example:Given s = “hello”, return “olleh”. 解决方案1234567public class Solution { public String reverseString(S

0

leetcode [#299]

题目 You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint

0

leetcode [#341]

题目 Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list – whose elements may also be integers or other lists. Example:Given the list [[1,

0

leetcode [#326]

题目 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 / recursion? 解决方案12345678910111213public class Solution { publ

0

leetcode [#292]

题目 You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be