Skip to content

Commit 5eb247a

Browse files
committed
Update birthday.java
1 parent ac4e448 commit 5eb247a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Hackerrank/birthday.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
/* You are in charge of the cake for a child's birthday. You have decided the cake will have one candle
2+
for each year of their total age. They will only be able to blow out the tallest of the candles.
3+
Count how many candles are tallest. A Program to input candle heights and print the total number
4+
of tallest candles present on the cake*/
15
import java.io.*;
26
import java.util.Arrays;
37
class birthday
48
{
59
int candle_count(int [] a, int x) //a method to sort and calculate the number of candles.
610
{
7-
Arrays.sort(a); //to sort the elements in asscending order
11+
Arrays.sort(a); //to sort the elements in ascending order
812
int c=0;
913
int lst= a[x-1];
1014
for(int i=x-1;i>=0;i--)
@@ -24,7 +28,7 @@ public static void main() throws IOException
2428
for(int i=0;i<ln;i++)
2529
{
2630
cdl[i]=Integer.parseInt(br.readLine());
27-
if(cdl[i]==0)
31+
if(cdl[i]==0) //this will ensure that the input is not 0
2832
i=i-1;
2933
}
3034
birthday obj= new birthday();

0 commit comments

Comments
 (0)