Quick actions

cmd+k|ctrl+k

Navigation

Languages

bird sum   --------------               

Snippet info

Language

JavaScript

Visibility

public

Author

krishnakanth

Created

2022-09-21T05:36:06.732035Z

Updated

2022-09-21T05:36:06.732035Z

    // 6
    // 1 4 4 4 5 3
    function processData(input) {
            
        field = input.split("\n")
        arr   = field[1].split(" ") 
        arr   = arr.map(Number)
        max   = 0
        count =  new Array(6);
        count.fill(0)

        for (let i = 0; i < arr.length; i++) {
            count[arr[i]]++
            
        }

        formax = 0 
        for (let i = 1; i < 6; i++) {
           if (count[i] > max) {
                max = count[i]
                formax = i
           }
            
        }

        console.log(formax);
 

        

    }
        
    process.stdin.resume();
    process.stdin.setEncoding("ascii");
    _input = "";
    process.stdin.on("data", function (input) {
        _input += input;
    });

    process.stdin.on("end", function () {
        processData(_input);
    });
INFO