随笔分类 - OJ
摘要:题目链接Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.分析:一般一个题目我首先会想想怎么暴力解决,比如这一题,可...
阅读全文
摘要:题目链接Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the ...
阅读全文
摘要:题目链接Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the o...
阅读全文
摘要:题目链接Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representa...
阅读全文
摘要:题目链接Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional element...
阅读全文
摘要:题目链接The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total nu...
阅读全文
摘要:题目链接A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message c...
阅读全文
摘要:求集合的所有子集问题LeetCode:SubsetsGiven a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.Th...
阅读全文
摘要:题目链接Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another exp...
阅读全文
摘要:题目链接Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NUL...
阅读全文
摘要:题目链接Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["2...
阅读全文
摘要:LeetCode:Unique Binary Search TreesGivenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there...
阅读全文
摘要:题目链接Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.When...
阅读全文
摘要:题目链接Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains on...
阅读全文
摘要:其他LeetCode题目欢迎访问:LeetCode结题报告索引题目链接Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.N...
阅读全文
摘要:题目链接Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2]....
阅读全文
摘要:题目链接Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.分析:首先要注意的是,输入数组中可能有重复的点。由于两点确定一条直线,一个很直观的解法是计算每两个...
阅读全文
摘要:其他LeetCode题目欢迎访问:LeetCode结题报告索引LeetCode:Word LadderGiven two words (startandend), and a dictionary, find the length of shortest transformation sequenc...
阅读全文
摘要:题目链接Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identica...
阅读全文
摘要:题目链接Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 /...
阅读全文