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

随笔分类 -  数据结构与算法

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) 编辑

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) 编辑

回溯法解符号三角形
摘要:消化一个算法最重要的是理解他的思想,而不是急于搞定代码,写文章重要的是阐明道理,而不是简单的粘贴代码,这篇文章需要详细的分析!符号三角形问题是经典的回溯问题,下图是一个符号三角形+ + - ++ - - - + -这个三角形的组成规则是,只能由+和-组成,并且两个相同符号的下面是+,两个不同符号下面是-,设符号三角形第一行有n个符号,对于给定的n,计算有多少种不同的符号三角形,使得+和-的个数相等。例如,当n=4时,共有如下六种符号三角形满足条件+ + - ++ - - - + -+ + - -+ - + - - ++ - + +- - + + - -+ - + -- - - + + +- + 阅读全文

posted @ 2009-05-26 09:30 翰墨小生 阅读(1669) 评论(2) 推荐(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
点击右上角即可分享
微信分享提示