Created
March 7, 2017 13:46
-
-
Save tkrshn/e04e880aaec24778ce69bcd05dc678da to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/bibiwe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
"use strict"; | |
function main(input) { | |
//Enter your code here | |
//process.stdout.write("Hello World!"); | |
var stud_arr = []; | |
var lines = input.split('\n'); | |
var no_of_students = parseInt(lines[0]); | |
for (var i = 0; i < no_of_students; i++) { | |
var stud_arr_idx = parseInt(lines[i + 1].split(" ")[0]); | |
stud_arr[stud_arr_idx] = lines[i + 1].split(" ")[1]; | |
} | |
var no_of_queries = parseInt(lines[no_of_students + 1]); | |
for (var j = 1; j <= no_of_queries; j++) { | |
var idx = parseInt(lines[no_of_students + 1 + j]); | |
console.log(idx + ": " + stud_arr[idx]); | |
} | |
} | |
data = '3\n1 thulasi\n2 jyothi\n3 rajat\n3\n2\n3\n1'; | |
main(data); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function main(input) { | |
//Enter your code here | |
//process.stdout.write("Hello World!"); | |
let stud_arr = []; | |
let lines = input.split('\n'); | |
let no_of_students = parseInt(lines[0]); | |
for(let i=0;i<no_of_students;i++){ | |
let stud_arr_idx = parseInt(lines[i+1].split(" ")[0]); | |
stud_arr[stud_arr_idx] = lines[i+1].split(" ")[1]; | |
} | |
let no_of_queries = parseInt(lines[no_of_students + 1]); | |
for(let j = 1; j<=no_of_queries;j++){ | |
let idx = parseInt(lines[no_of_students + 1 + j]); | |
console.log(`${idx}: ${stud_arr[idx]}`); | |
} | |
} | |
data = '3\n1 thulasi\n2 jyothi\n3 rajat\n3\n2\n3\n1'; | |
main(data);</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
function main(input) { | |
//Enter your code here | |
//process.stdout.write("Hello World!"); | |
var stud_arr = []; | |
var lines = input.split('\n'); | |
var no_of_students = parseInt(lines[0]); | |
for (var i = 0; i < no_of_students; i++) { | |
var stud_arr_idx = parseInt(lines[i + 1].split(" ")[0]); | |
stud_arr[stud_arr_idx] = lines[i + 1].split(" ")[1]; | |
} | |
var no_of_queries = parseInt(lines[no_of_students + 1]); | |
for (var j = 1; j <= no_of_queries; j++) { | |
var idx = parseInt(lines[no_of_students + 1 + j]); | |
console.log(idx + ": " + stud_arr[idx]); | |
} | |
} | |
data = '3\n1 thulasi\n2 jyothi\n3 rajat\n3\n2\n3\n1'; | |
main(data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment