Tag Archives: nodejs

Birthday Cake Candles

Colleen is turning  years old! Therefore, she has  candles of various heights on her cake, and candle  has height . Because the taller candles tower over the shorter ones, Colleen can only blow out the tallest candles.

Given the  for each individual candle, find and print the number of candles she can successfully blow out.

Input Format

The first line contains a single integer, , denoting the number of candles on the cake.
The second line contains  space-separated integers, where each integer  describes the height of candle .


Output Format

Print the number of candles Colleen blows out on a new line.

Sample Input 0

3 2 1 3

Sample Output 0


Explanation 0

We have one candle of height , one candle of height , and two candles of height . Colleen only blows out the tallest candles, meaning the candles where . Because there are  such candles, we print  on a new line.

Solution Answer


var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");

function readLine() {
    return input_stdin_array[input_currentline++];

/////////////// ignore above this line ////////////////////

function birthdayCakeCandles(n, ar) {
   var max=ar[0];
   var num=1;
 for (var i=1;i<n; i++){
   if (ar[i]>max){ 
   else if (ar[i]==max) num++;
  return num;

function main() {
    var n = parseInt(readLine());
    ar = readLine().split(' ');
    ar = ar.map(Number);
    var result = birthdayCakeCandles(n, ar);
    process.stdout.write("" + result + "\n");



Building a website with node.js–to be continue

This will inlude knowledge of express,view engines,controllers,services,static resources,client-side dependencies.

After you installed the node.js tools for Visio Studio, when you start create a new project you could choose build a nodejs website

nodejs website

Once you created it, the package.json is like your create other project,this is to know what dependence I used in my project.

Clear your server.js code.


Now just run your server.js first, you could open a browser you could the request in your server