This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package POJ; | |
public class Main { | |
/** | |
* | |
* 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 representing n cents. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package POJ; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
public class Main { | |
/** | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package POJ; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
public class Main { | |
/** | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package POJ; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
public class Main{ | |
/** | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package POJ; | |
public class Main{ | |
/** | |
* | |
* 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 index, if one exists, in array A. | |
* FOLLOW UP | |
* What if the values are not distinct? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package POJ; | |
public class Main{ | |
/** | |
* | |
* Now consider if some obstacles are added to the grids. How many unique paths would there be? | |
* An obstacle and empty space is marked as 1 and 0 respectively in the grid. | |
* | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package POJ; | |
public class Main{ | |
/** | |
* | |
* 9.1 A child is running up a staircase with n steps, and can hop either 1 step, 2 steps, or 3 steps at | |
* a time. Implement a method to count how many possible ways the child can run up the stairs. | |
* | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package POJ; | |
import java.awt.Point; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.LinkedList; | |
import java.util.Queue; | |
public class Main{ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package POJ; | |
import java.awt.Point; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
public class Main{ | |
/** | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package POJ; | |
import java.util.ArrayList; | |
public class Main{ | |
/** | |
* | |
* 7.4 Write methods to implement the multiply, subtract and divide operations for integers. Use only the add operator. | |
* |
NewerOlder