书法字典:https://www.shufadict.com

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 翰墨小生 阅读(548) 评论(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 翰墨小生 阅读(455) 评论(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 翰墨小生 阅读(411) 评论(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 翰墨小生 阅读(392) 评论(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 翰墨小生 阅读(384) 评论(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 翰墨小生 阅读(526) 评论(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 翰墨小生 阅读(556) 评论(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 翰墨小生 阅读(23818) 评论(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 翰墨小生 阅读(447) 评论(0) 推荐(0) 编辑

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

posted @ 2009-06-03 14:00 翰墨小生 阅读(2471) 评论(5) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
书法字典:https://www.shufadict.com
点击右上角即可分享
微信分享提示