随笔分类 - LeetCode
摘要:Add and Search Word - Data structure design (M) 题目 Design a data structure that supports the following two operations: void addWord(word) bool search(
阅读全文
摘要:Implement Trie (Prefix Tree) (M) 题目 Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"
阅读全文
摘要:Power of Four (E) 题目 Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example 1: Input: 16 Output: true Exampl
阅读全文
摘要:Valid Palindrome (E) 题目 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the pu
阅读全文
摘要:Design HashSet (E) 题目 Design a HashSet without using any built-in hash table libraries. To be specific, your design should include these functions: ad
阅读全文
摘要:Detect Capital (E) 题目 Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word t
阅读全文
摘要:Climbing Stairs (E) 题目 You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many d
阅读全文
摘要:Word Break II (H) 题目 Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentenc
阅读全文
摘要:Best Time to Buy and Sell Stock with Cooldown (M) 题目 Say you have an array for which the ith element is the price of a given stock on day i. Design an
阅读全文
摘要:Task Scheduler (M) 题目 You are given a char array representing tasks CPU need to do. It contains capital letters A to Z where each letter represents a
阅读全文
摘要:Construct Binary Tree from Inorder and Postorder Traversal (M) 题目 Given inorder and postorder traversal of a tree, construct the binary tree. Note: Yo
阅读全文
摘要:Add Digits (E) 题目 Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Example: Input: 38 Output: 2 Ex
阅读全文
摘要:Find Minimum in Rotated Sorted Array II (H) 题目 Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [
阅读全文
摘要:All Paths From Source to Target (M) 题目 Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and return them in
阅读全文
摘要:Single Number III (M) 题目 Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twic
阅读全文
摘要:Edit Distance (H) 题目 Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following
阅读全文
摘要:Binary Tree Zigzag Level Order Traversal (M) 题目 Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to r
阅读全文
摘要:Burst Balloons (H) 题目 Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to
阅读全文
摘要:Word Search (M) 题目 Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent
阅读全文
摘要:Add Binary (E) 题目 Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters
阅读全文

浙公网安备 33010602011771号