02 2019 档案
摘要:52. N-Queens II 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 intege
阅读全文
摘要:51. N-Queens 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
阅读全文
摘要:50. Pow(x, n) Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Example 2: Example 3:
阅读全文
摘要:49. Group Anagrams Given an array of strings, group anagrams together. Example:
阅读全文
摘要:48. Rotate Image You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the imag
阅读全文
摘要:47. Permutations II Given a collection of numbers that might contain duplicates, return all possible unique permutations. Example:
阅读全文
摘要:46. Permutations Given a collection of distinct integers, return all possible permutations. Example:
阅读全文
摘要:45. Jump Game II Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array repr
阅读全文
摘要:44. Wildcard Matching Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. The matching shou
阅读全文
摘要:43. Multiply Strings Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a
阅读全文
摘要:42. Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is abl
阅读全文
摘要:41. First Missing Positive Given an unsorted integer array, find the smallest missing positive integer. Example 1: Example 2: Example 3:
阅读全文
摘要:40. Combination Sum II Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates w
阅读全文
摘要:39. Combination Sum Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in c
阅读全文
摘要:38. Count and Say The count-and-say sequence is the sequence of integers with the first five terms as following: 1 is read off as "one 1" or 11.11 is
阅读全文
摘要:37. Sudoku Solver Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Empt
阅读全文
摘要:36. Valid Sudoku Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: A partially fi
阅读全文
摘要:35. Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would b
阅读全文
摘要:34. Find First and Last Position of Element in Sorted Array Given an array of integers nums sorted in ascending order, find the starting and ending po
阅读全文
摘要:33. Search in Rotated Sorted Array Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,
阅读全文
摘要:32. Longest Valid Parentheses Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parenthese
阅读全文
摘要:31. Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arra
阅读全文
摘要:30. Substring with Concatenation of All Words You are given a string, s, and a list of words, words, that are all of the same length. Find all startin
阅读全文
摘要:29. Divide Two Integers Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator. Return t
阅读全文
摘要:28. Implement strStr() Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Ex
阅读全文
摘要:27. Remove Element 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 s
阅读全文
摘要:26. Remove Duplicates from Sorted Array Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return t
阅读全文
摘要:25. Reverse Nodes in k-Group Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer
阅读全文
摘要:24. Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, onl
阅读全文
摘要:23. Merge k Sorted Lists Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example:
阅读全文
摘要:22. Generate Parentheses Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n
阅读全文
摘要:21. Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of th
阅读全文
摘要:20. Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input
阅读全文
摘要:19. Remove Nth Node From End of List Given a linked list, remove the n-th node from the end of list and return its head. Example:
阅读全文
摘要:18. 4Sum Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all
阅读全文
摘要:17. Letter Combinations of a Phone Number Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number
阅读全文
摘要:16. 3Sum Closest Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return t
阅读全文
摘要:15. 3Sum Given an array nums of n integers, are there elements a, b, c in nums such that a + b+ c = 0? Find all unique triplets in the array which giv
阅读全文
摘要:14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return
阅读全文
摘要:13. Roman to Integer Roman numerals are represented by seven different symbols: I, V, X, L, C, Dand M. For example, two is written as II in Roman nume
阅读全文
摘要:12. Integer to Roman Roman numerals are represented by seven different symbols: I, V, X, L, C, Dand M. For example, two is written as II in Roman nume
阅读全文
摘要:11. Container With Most Water Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines ar
阅读全文
摘要:10. Regular Expression Matching Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. The m
阅读全文
摘要:9. Palindrome Number Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: E
阅读全文
摘要:8. String to Integer (atoi) Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessa
阅读全文
摘要:7. Reverse Integer Given a 32-bit signed integer, reverse digits of an integer. Example 1: Example 2: Example 3:
阅读全文
摘要:6. ZigZag Conversion The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pat
阅读全文
摘要:给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 1: 输入: "babad"输出: "bab"注意: "aba" 也是一个有效答案。示例 2: 输入: "cbbd"输出: "bb" Given a string s, find the longest
阅读全文
摘要:给定两个大小为 m 和 n 的有序数组 nums1 和 nums2。 请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。 你可以假设 nums1 和 nums2 不会同时为空。 示例 1: nums1 = [1, 3]nums2 = [2] 则中位数是 2.0示
阅读全文
摘要:给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: "abcabcbb"输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。示例 2: 输入: "bbbbb"输出: 1解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。示例 3:
阅读全文
摘要:给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。 示例: 输入:(2 -> 4 ->
阅读全文
摘要:给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 num
阅读全文