第一种方法,用栈实现,最容易想到,也比较容易实现,每次碰到‘)’时update
max_len,由于要保存之前的‘(’的index,所以spacecomplexity 是O(n) 1 // 使用栈,时间复杂度 O(n),空间复杂度 O(n)
2 class Solution { 3 publ...
分类:
其他好文 时间:
2014-06-11 09:16:10
阅读次数:
197
#include#include#define MAX_VERTEX_NUM 10typedef
char VertexType;typedef struct ArcNode//边 { int adjvex; struct ArcNode *nextarc;
in...
分类:
其他好文 时间:
2014-06-11 09:03:34
阅读次数:
277
脑残wa了一次 1 var s:ansistring; 2
ans,i,k,m:longint; 3 pre:array[0..1010000] of longint; 4 function
max(x,y:longint):longint; 5 begin 6 if x>...
分类:
其他好文 时间:
2014-06-11 08:30:14
阅读次数:
179
/** linux/tools/build.c** Copyright (C) 1991,
1992 Linus Torvalds*//** This file builds a disk-image from three different
files:** - bootsect: max 510...
分类:
其他好文 时间:
2014-06-08 08:04:19
阅读次数:
344
PathsumDescription:Given a binary tree and a
sum, determine if the tree has a root-to-leaf path such that adding up all the
values along the path equa...
分类:
其他好文 时间:
2014-06-08 01:11:46
阅读次数:
395
给定两个数m,n,其中m是一个素数。 将n(0=n) { sum+=m/n m=m/n; }
分类:
其他好文 时间:
2014-06-08 00:20:05
阅读次数:
348
可变参数可变参数可以当成一个数组使用public void sum(int ...nums){
int sum = 0; for(int i:nums) { sum +=i; } System.out.pri...
分类:
编程语言 时间:
2014-06-07 22:42:41
阅读次数:
306
Given amxngrid filled with non-negative
numbers, find a path from top left to bottom right whichminimizesthe sum of all
numbers along its path.Note:Yo...
分类:
其他好文 时间:
2014-06-07 20:22:17
阅读次数:
264
Given a non-negative number represented as an
array of digits, plus one to the number.The digits are stored such that the most
significant digit is at...
分类:
其他好文 时间:
2014-06-07 16:56:28
阅读次数:
188
Given a binary tree and a sum, determine if the
tree has a root-to-leaf path such that adding up all the values along the path
equals the given sum.Fo...
分类:
其他好文 时间:
2014-06-07 16:55:09
阅读次数:
173