摘要:
题意:紧贴x轴有一些相互挨着的矩形,给定每个矩形的长宽,问他们可以形成的最大矩形是多少。Sample Input31 23 41 233 41 23 4-1Sample Output1214 1 #include 2 #include 3 #include 4 5 using namespa... 阅读全文
摘要:
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes... 阅读全文
摘要:
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the c... 阅读全文
摘要:
Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?回文链表即原链表与逆置链表相同,采用辅助栈的特点将链表逆置。(知道链表长... 阅读全文
摘要:
Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = ... 阅读全文
摘要:
Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->... 阅读全文
摘要:
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.N... 阅读全文
摘要:
Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,... 阅读全文
摘要:
题目:给定一个字符串,问最少插入多少字符,使字符串变成回文字符串。思路:X:原字符串 Y:逆字符串 需要插入的字符数=X的长度-(X与Y的LCS的长度) 这里使用了滚动数组,压缩空间,原因:d[i][j]只依赖于 d[i-1][j] d[i][j-1] 1 #include 2 #include... 阅读全文
摘要:
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 distinct ways can you cli... 阅读全文