06 2009 档案

DP_knapsack
摘要:动态规划法解0-1背包问题问题描述:有n个背包,重量依次为w1,w2, ... ,wn, 价值依次是v1,v2, ... ,vn, 现在有一个大背包,其容量是capacity,往其中装小背包,要求得到的总价值最大,如何装?用value[i, w]表示有i个背包且总重量最大是w时的价值,那么当考虑第i个背包时,有两种情况1. 将此背包装入大包,价值是 v[i] + value[i - 1, w- w... 阅读全文

posted @ 2009-06-23 16:55 前端风云志 阅读(554) 评论(0) 推荐(0)

Maximum Subsequence Multiplication
摘要:Given an array a contains integers, returnthe maximum consecutive multiplication Example:int[] a = {2, -2, -3, 4, -5, 6} ;return 360 (-3 * 4 * -5 * 6)code[代码] 阅读全文

posted @ 2009-06-10 16:02 前端风云志 阅读(465) 评论(0) 推荐(0)

Maximum subsequence sum
摘要:This is a very famous problem from programming pealsGiven an array of integers, return the maximum subsequence sum of the array, if the maximus sumless than 0, return 0Example1, 2, -6, 3, -2, 4, -1, 3... 阅读全文

posted @ 2009-06-09 17:08 前端风云志 阅读(420) 评论(0) 推荐(0)

Consecutive sequence with sum 0
摘要:You are given an integer array which contains positive integers, zero and negetive integerscount how many consecutive sequences in this array make a sum of 0.exmapleint[] a = {4, -1, 2, 1, -2, -1, 5, ... 阅读全文

posted @ 2009-06-09 16:26 前端风云志 阅读(410) 评论(0) 推荐(0)

Shortest distance between two arrays
摘要:Given two sorted array in non-descending order, each contains positive integersThe distance is define as followingpick up a number from each array, compute their differencereturn the shortest distance... 阅读全文

posted @ 2009-06-07 16:07 前端风云志 阅读(407) 评论(0) 推荐(0)

Plateau problem
摘要:Given a sorted array in non-descending order, the element type can be positive integer or char, return the length of the longest consecutive segmentsExample, Input:"1223334556", output 3Input: "abccde... 阅读全文

posted @ 2009-06-06 12:50 前端风云志 阅读(536) 评论(0) 推荐(0)

DP_LCS
摘要:The Longest Common Subsequence problemGive two strings a and b. return the length of the longest common subsequence of them.Note: characters in subsequence needn’t to be consecutive, but in subs... 阅读全文

posted @ 2009-06-05 12:01 前端风云志 阅读(571) 评论(1) 推荐(0)

一维数组和二维数组的转换表示(C#)
摘要:关键:下标的计算一维->二维一个n个元素的一维数组,转换为r行c列的二维数组对于一维数组中任意一个元素的下标i(0 <= i < n)其对应的二维数组下标为 (i / c, i % c), 显然, 只与列数c有关,而与行数r无关code like this[代码]also can write like this[代码]二维->一维[代码] 阅读全文

posted @ 2009-06-04 15:00 前端风云志 阅读(23878) 评论(1) 推荐(2)

BackTracking_Fixed sum for array elements
摘要:Given an array a contains distinct positive integers, count how many combinations of integers in a add up to exactly sumFor example, given int[] a = {... 阅读全文

posted @ 2009-06-03 16:36 前端风云志 阅读(455) 评论(0) 推荐(0)

BSP 面试总结
摘要:指针参数 当指针作为函数参数时,对参数本身的修改并不影响原来的值,比如下面的代码,删除链表中第一个值为item的结点。但是结果却不正确。 void Delete(Node *head, int item){ if(head->value == item) head = NULL ;} 这段代码的问题 阅读全文

posted @ 2009-06-03 14:00 前端风云志 阅读(2498) 评论(5) 推荐(0)

导航

关注我

前端风云志