Skip to content

Instantly share code, notes, and snippets.

View NRKishanKumar's full-sized avatar

NRKishanKumar

View GitHub Profile
@NRKishanKumar
NRKishanKumar / arrayFilterPrime.js
Last active February 23, 2024 08:48
Find prime numbers in an array - Javascript
var a = [5, 9, 63, 29, 35, 6, 55, 23]
var prime = [];
function isPrime(item) {
var identifier = item / 2;
for (var j = 2; j <= identifier; j++) {
if ((item % j) == 0) { // modulous
return false;
}
}
@NRKishanKumar
NRKishanKumar / Athest_visits_city_nottemple_solution.js
Last active October 23, 2021 05:00
There are n cities numbered from 1 to n and there are n-1 bidirectional roads such that all cities are connected. There are k temples, each one is in a different city. you are an athiest and currently in the 1st city. You want to visit city X such that neither X not the cities in the path from 1 to X has a temple. Find out how many such X you ca…
process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = [];
process.stdin.on("data", function (input) {
stdin_input.push(input.replace("\n", "").split(" ").map(Number));
});
process.stdin.on("end", function () {
main(stdin_input);