随笔分类 - LeetCode
摘要:Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring. Example 1: Inpu
阅读全文
摘要:Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if:
阅读全文
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9
阅读全文
摘要:Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the dig
阅读全文
摘要:Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numb
阅读全文
摘要:Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen nu
阅读全文
摘要:Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found
阅读全文
摘要:Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if i
阅读全文
摘要:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen
阅读全文
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Exampl
阅读全文
摘要:Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where: '?' Matches any single character.
阅读全文
摘要:Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an algorithm that runs in O(n) time and uses O(
阅读全文
摘要:Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You mus
阅读全文
摘要:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl...
阅读全文
摘要:You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means
阅读全文
摘要:Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearrang
阅读全文
摘要:Implement pow(x, n), which calculates x raised to the power n (i.e., x^n). Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input:
阅读全文
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo
阅读全文
摘要:The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return th
阅读全文
摘要:The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return al
阅读全文