9.8 Given an infinite number of quarters (25 cents), dimes (10 cents), nickels (5 cents) and pennies (1 cent), write code to calculate the number of ways of rep ...
9.10 You have a stack of n boxes, with widths w1, heights h1 and depths d1. The boxes cannot be rotated and can only be stacked on top of one another if each b ...
9.11 Given a boolean expression consisting of the symbols 0,1, &, /, and ^, and a desired boolean result value result, implement a function to count the number ...
9.9 Write an algorithm to prim all ways of arranging eight queens on an 8x8 chess board so that none of them share the same row, column or diagonal. In this cas ...
9.7 Implement the "paint fill" function that one might see on many image editing programs. That is, given a screen (represented by a two-dimensional array of co ...
已1->4->6 + 2->7->9=4->2->5为例,①sum=1+2+sumHelper(result,list1,list2);②sum=4+7+sumHelper(result,list1,list2);③sum=6+9+sumHelper(result,list1,list2) ...
9.6 Implement an algorithm to print all valid (i.e., properly opened and closed) combinations of n-pairs of parentheses.回复解法可以按照以下格式来 ...
为啥不是M+N?
9.5 Write a method to compute all permutations of a string回复解法可以按照以下格式来【解题思路】【时间复杂度】【空间复杂度】【gist link】----- ...
9.4 Write a method to return all subsets of a set.回复解法可以按照以下格式来【解题思路】【时间复杂度】【空间复杂度】【gist link】------------- ...
9.3 A magic index in an array A[1.. .n-1] is defined to be an index such that A =i. Given a sorted array of distinct integers, write a method to find a magic in ...
[code]package Chapter2;public class partition {public static void partition(MyLinkedList list,int k){Node BeforeStart=null;//左边是Node的引用,这个 ...
创建节点:this(nodeValue, null)这句是不是this.nodeValue = nodeValue; this.next = null; 的意思啊?为什么这里的null不用大写呢?
哪里有源代码下载啊?就是可以编译的
题意是一个文件里面有1G的不重复的非负整数,只有10M的内存,找出一个不在文件里面的非负整数。解法和他一样,划分区间再统计,但是智商拙计没有看懂他后面对区间大 ...
[code]public class Q1_7{public static void SetZero( int[][] matrix){boolean [] row= new boolean[ matrix. length ]; //二维矩阵的长度指行数,并且和 ...
LZ卸了eclipse,装了个新的操蛋IDE,还没摸索完,这玩意不提示错误,就说了非法表达式,你妹![code]public class Q1_5{public static void rotate(int matrix[][],int n ...
有几个问题:第一行:一般字符数组的末尾是‘\0’吧,这个因为是char *str,所以最后一位是NULL?第四行: 感觉外面这个if(str)可以不要吧
实现一个算法来判断一个字符串中的字符是否唯一(即没有重复).不能使用额外的数据结构。 (即只使用基本的数据结构)[code] public boolean isUniqueChars2(String str) { ...