随笔分类 -  Leetcode

摘要:Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adja 阅读全文
posted @ 2017-07-23 04:13 白天黑夜每日c 阅读(127) 评论(0) 推荐(0)
摘要: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 cell, where "adjac 阅读全文
posted @ 2017-07-23 04:12 白天黑夜每日c 阅读(140) 评论(0) 推荐(0)
摘要:Design a data structure that supports the following two operations: search(word) can search a literal word or a regular expression string containing o 阅读全文
posted @ 2017-07-23 04:11 白天黑夜每日c 阅读(158) 评论(0) 推荐(0)
摘要:Implement a trie with insert, search, and startsWith methods. Note:You may assume that all inputs are consist of lowercase letters a-z. Implement a tr 阅读全文
posted @ 2017-07-23 04:10 白天黑夜每日c 阅读(160) 评论(0) 推荐(0)
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文
posted @ 2017-07-17 05:34 白天黑夜每日c 阅读(135) 评论(0) 推荐(0)
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3 阅读全文
posted @ 2017-07-17 05:31 白天黑夜每日c 阅读(128) 评论(0) 推荐(0)
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its ne 阅读全文
posted @ 2017-07-17 05:29 白天黑夜每日c 阅读(122) 评论(0) 推荐(0)
摘要:Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution sti 阅读全文
posted @ 2017-07-17 05:28 白天黑夜每日c 阅读(139) 评论(0) 推荐(0)
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 阅读全文
posted @ 2017-07-16 22:59 白天黑夜每日c 阅读(97) 评论(0) 推荐(0)
摘要:Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution using O(n) space 阅读全文
posted @ 2017-07-16 22:46 白天黑夜每日c 阅读(135) 评论(0) 推荐(0)
摘要:Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree [1,null,2,3], 1 \ 2 / 3 return [1,3,2]. Note: Re 阅读全文
posted @ 2017-07-16 22:23 白天黑夜每日c 阅读(142) 评论(0) 推荐(0)
摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia 阅读全文
posted @ 2017-07-16 21:48 白天黑夜每日c 阅读(148) 评论(0) 推荐(0)
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST' 阅读全文
posted @ 2017-07-16 21:48 白天黑夜每日c 阅读(120) 评论(0) 推荐(0)
摘要:Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia:This problem was inspired by this original tweet by Max Howell: Go 阅读全文
posted @ 2017-07-16 21:47 白天黑夜每日c 阅读(140) 评论(0) 推荐(0)
摘要:Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front 阅读全文
posted @ 2017-07-14 23:00 白天黑夜每日c 阅读(115) 评论(0) 推荐(0)
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov 阅读全文
posted @ 2017-07-14 12:12 白天黑夜每日c 阅读(139) 评论(0) 推荐(0)
摘要: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 @ 2017-07-14 12:11 白天黑夜每日c 阅读(401) 评论(0) 推荐(0)
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文
posted @ 2017-07-14 12:11 白天黑夜每日c 阅读(142) 评论(0) 推荐(0)
摘要:Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or 阅读全文
posted @ 2017-07-14 12:10 白天黑夜每日c 阅读(187) 评论(0) 推荐(0)
摘要:Given an integer, write a function to determine if it is a power of three. 阅读全文
posted @ 2016-03-29 18:01 白天黑夜每日c 阅读(145) 评论(0) 推荐(0)