This problem can be solved elegantly using dynamic programming.We maintain two arrays:cnt[i][j] --- number of parentheses needed to add within s[i..j]...
分类:
其他好文 时间:
2015-06-22 19:12:15
阅读次数:
202
题目链接:https://leetcode.com/problems/3sum-closest/
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three i...
分类:
其他好文 时间:
2015-06-22 17:56:00
阅读次数:
110
解题思路:
A—Z 26个字母,AA出现27,则进制为26,。因此只需将给定字符串从高为到低位依次遍历,然后运算即可。...
分类:
其他好文 时间:
2015-06-22 11:10:14
阅读次数:
135
Given a complete binary tree, count the number of nodes.
Definition of a complete binary tree from Wikipedia:
In a complete binary tree every level, except possibly the last, is completely filled,...
分类:
其他好文 时间:
2015-06-22 09:55:34
阅读次数:
149
非常巧,前后做了两次,写的代码思路、甚至是空行都是一模一样的...
代码:
class Solution
{
public:
bool isHappy(int n)
{
if (int_set.find(n) != int_set.end())
{
return false;
}
int_set.insert(n)...
分类:
移动开发 时间:
2015-06-22 09:53:56
阅读次数:
140
Dscription:Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear r...
分类:
其他好文 时间:
2015-06-21 18:21:49
阅读次数:
83
1、SCOTT用户之中的主要数据表 dept、emp、salgrade、bonus。观察四张表结构(语法:DESC 表)。 |·部门表:dept NO. 字段 类型 描述 1、 DEPTNO NUMBER...
分类:
数据库 时间:
2015-06-21 18:21:21
阅读次数:
198
题目:题目太长了,见链接-- >The Skyline ProblemNotes:The number of buildings in any input list is guaranteed to be in the range[0, 10000].The input list is alread...
分类:
编程语言 时间:
2015-06-21 17:13:06
阅读次数:
166
题目链接:https://leetcode.com/problems/palindrome-number/
Determine whether an integer is a palindrome. Do this without extra space.
click to show spoilers.
Some hints:
Could negative inte...
分类:
其他好文 时间:
2015-06-21 15:52:27
阅读次数:
145
Description
Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares...
分类:
其他好文 时间:
2015-06-21 14:33:04
阅读次数:
155