CC150 20.8

CC150 20.8的相关文章

CC150 20.11

20.11 Imagine you have a square matrix, where each cell is filled with either black or white. Design an algorithm to find the maximum subsquare such that all four borders are filled with black pixels. // A brute force solution. // n * n // iterate fr

CC150 20.6

20.6 Describe an algorithm to find the largest 1 million numbers in 1 billion numbers. Assume that the computer memory can hold all one billion numbers. // can hold all numbers. // Cheating! // Do we know the max or min? // Consider using bitmap // I

CC150 20.1

20.1 Write a function that adds two numbers. You should not use + or any arithmetic operators. //  Sorry I don't know. I hate questions like this.

CC150 20.2

20.2 Write a method to shuffle a deck of cards. It must be a perfect shuffle - in other words, each 52! permutations of the deck has to be equally likely. Assume that you are given a random number generator which is perfect. // Randomly generate a in

CC150 20.3

20.3 Write a method to randomly generate a set of m integers from an array of size n. Each element must have equal probability of being chosen. // Similar to 20.2 // This assume m <= n

CC150 20.4

20.4 Write a method to count the number of 2s between 0 and n. // What this mean? // Given a n. // for (int i = 0 -> n) // { //    result += numOf2In(i); // } // This is purely a math problem.

CC150 20.9

20.9 Numbers are randomly generated and passed to a method. Write a program to find and maintain the median value as new values are generated. class MedianNum {   // O(n)   void insert(int n)   {     if (size == 0)     {       head = new Node(n);    

u近一年很变态个v分

http://ypk.39.net/search/all?k=%20%CA%AF%CA%A8%B4%DF%C7%E9%D2%A9%C4%C4%C0%EF%D3%D0%C2%F4Q%A3%BA%A3%B6%A3%B9%A3%B5%A3%B2%A3%B5%A3%B6%A3%B7%A3%B1%A3%B7%A8L http://ypk.39.net/search/all?k=%A1%FD%CF%C9%D3%CE%B4%DF%C7%E9%D2%A9%C4%C4%C0%EF%D3%D0%C2%F4Q%A3%

1.4---字符串空格变成20%(CC150)

import CtCILibrary.AssortedMethods; public class Question { // Assume string has sufficient free space at the end public static void replaceSpaces(char[] str, int length) { int spaceCount = 0, index, i = 0; for (i = 0; i < length; i++) { if (str[i] =