Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

HackerEarth JavaScript solutions

function main(input) {
    //Enter your code here
    var data = input.split('
');
    var firstLine = data[0].split(' ');
    var len = firstLine[0];
    //process.stdout.write('length:'+len);
    var toFind = firstLine[1];
    //process.stdout.write('toFind:'+toFind);
    //process.stdout.write('
');
    var arr = data[1].split(' '); 
    //process.stdout.write(arr);
    for(var i=len-1;i>=0;i--) {
        if(arr[i] == toFind){
            process.stdout.write(i+1);
            return;
        }
    }
    process.stdout.write(-1);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: hello world react 
Javascript :: react enzyme 
Javascript :: push object to json array 
Javascript :: Not Found The requested URL was not found on this server angular routing when going back to site from ecternal source 
Javascript :: Check for mobile device 
Javascript :: how to make bootstrap navbar to change on scroll 
Javascript :: post to /wp-json/wp/v2/media 
Javascript :: today date selected in datepicker 
Javascript :: javascript string to array 
Javascript :: javascript change select element 
Javascript :: why does an array index start at 0 
Javascript :: regex 
Javascript :: datatable table header not responsive 
Javascript :: An invalid form control with ... is not focusable. 
Javascript :: js sleep 1 sec 
Javascript :: merge objects javascript es6 
Javascript :: kubernetes taint master node 
Javascript :: mongoose findone multiple conditions 
Javascript :: react button onclick components 
Javascript :: word randomizer 
Javascript :: javascript set value html element by class 
Javascript :: regex negate 
Javascript :: js delete cookie by name 
Javascript :: axios get data from json file 
Javascript :: react hook form reset only one field 
Javascript :: nuxt store watch 
Javascript :: jest spyon 
Javascript :: named arguments in javascript 
Javascript :: destructuring assignment 
Javascript :: how to convert a number to a string in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =