Minimum Draws
The following is the solution to Hacker Rank problem Minimum Draws using Java. For solutions to other Hacker Rank Problem visit my page HackerRank, alternatively try searching for the problem in my blog.
Score:5/5
Score:5/5
/**
*
*/
import
java.io.BufferedReader;
import
java.io.InputStreamReader;
/**
* @author Arun.G
*
*/
public class Solution{
/**
* @param args
*/
static BufferedReader in = new BufferedReader(new InputStreamReader(
System.in));
//we need minimum of (noOfPairs+1) socks
to get a matched pair of socks
public static int minimumDraw(int noOfPairs)
{
return (noOfPairs+1);
}
public static void main(String[]
args) throws NumberFormatException,
Exception {
int T = Integer.parseInt(in.readLine());
//T test cases follow
for(int i=0;i<T;i++)
{
int noOfPairs =
Integer.parseInt(in.readLine());
System.out.println(minimumDraw(noOfPairs));
}
in.close();
}
}
|
No comments:
Post a Comment