Given an arraySofnintegers, are there
elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in
the array which gives the sum of ...
分类:
其他好文 时间:
2014-06-29 15:08:56
阅读次数:
263
2.1 Visual Studio 2005开发环境2.2 控制台应用程序
试试看:创建一个简单的控制台应用程序using System;using System.Collections.Generic;using
System.Linq;using System.Text;namespace C....
分类:
其他好文 时间:
2014-06-07 03:00:19
阅读次数:
241
都是考查DFS。经典回溯算法,问题在于我对该类型的代码不熟悉,目前以参考别人的代码,然后加上自己的实现为主,通过类似的题目加强理解。一、给定一棵二叉树,判断是否存在从root到leaf的路径和等于给定值sum,存在返回true,否则返回false。思路:DFS。代码:
1 private b...
分类:
其他好文 时间:
2014-05-28 23:51:25
阅读次数:
389
using System;using System.Collections.Generic;using
System.ComponentModel;using System.Data;using System.Drawing;using
System.Linq;using System.Text;u...
分类:
Web程序 时间:
2014-05-28 18:29:46
阅读次数:
378
Given an arraySofnintegers, are there
elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which
gives the sum of zero.Note:Elemen...
分类:
其他好文 时间:
2014-05-28 16:47:30
阅读次数:
308
在写LINQ语句的时候,往往会看到.AsEnumerable() 和
.AsQueryable() 。例如:string strcon ="Data Source=.\\SQLEXPRESS;Initial
Catalog=Db_Example;Persist Security Info=True;...
分类:
其他好文 时间:
2014-05-28 16:07:41
阅读次数:
418
问题来源于leetcode上的两道题 Path Sum I &&
II,分别写了两个dfs。1 void dfs(TreeNode node , int sum , ArrayList curPath)2 void
dfs(TreeNode node , int sum , boolean ifEx...
分类:
编程语言 时间:
2014-05-28 13:11:14
阅读次数:
361
//一个人从2000年1月1日开始三天打鱼两天晒网,用户输入一个日期,判断该人这天在打鱼还是晒网#include
void input();void sum(int y,int m,int d);int y,m,d;int main(void){
input(); sum(y,m,d); retu....
分类:
编程语言 时间:
2014-05-28 11:55:16
阅读次数:
289
题目:计算一棵二叉树所有路径组成的数的总和。思考:也是DFS的基础应用。虽然还是套着别人的DFS框架写的,但是学习通常会经历先模拟,再创新的过程。代码:
1 private int sum = 0; 2 public int sumNumbers(TreeNode root) { 3...
分类:
其他好文 时间:
2014-05-28 11:13:01
阅读次数:
225
函数实际上是对象,每个函数都是Function类型的实例。函数是引用类型。函数名实际上是一个执行函数对象的指针,不会与某个函数绑定。//
这种写法更能表达函数的本质var sum = function(num1, num2) { return num1 + num2;};var
another...
分类:
编程语言 时间:
2014-05-28 09:17:47
阅读次数:
454