Skip to content

Instantly share code, notes, and snippets.

View see-why's full-sized avatar
😇

Iyadi Cyril see-why

😇
View GitHub Profile
@see-why
see-why / 2d-array-hourglass-sum
Last active March 5, 2022 21:35
HackerRank 2d-arrays challenge solution
//My solution to this Hackerank challenge...https://www.hackerrank.com/challenges/30-2d-arrays/problem?isFullScreen=true
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', function(inputStdin) {
@see-why
see-why / timeConverter.js
Created December 16, 2021 07:36
Converting time in 12 hours to 24 hours
'use strict';
const fs = require('fs');
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
@see-why
see-why / between_two_sets.js
Created December 23, 2021 07:54
Between two sets HackerRank Challenge
function getTotalX(a, b) {
// Write your code here
let start = Math.max(...a);
let end = Math.min(...b);
let count = 0;
for(let i = start; i <= end; i++){
let arr_factors = a.filter((e) => i % e == 0);
let arr_multiples = b.filter((e) => e % i == 0);
//Hackerank challenge...https://www.hackerrank.com/challenges/grading/problem?isFullScreen=true
function gradingStudents(grades) {
// Write your code here
const newArray = grades.map((item) => {
if(item >= 38 ){
const quotient = Math.floor(item / 5);
const nextMultiple = (quotient + 1) * 5;
item = (nextMultiple - item) < 3 ? nextMultiple : item;
}
return item
@see-why
see-why / mybook.rb
Created January 11, 2022 07:58
HackerRank 30 days of code, Day 13 Abstract classes challenge
#https://www.hackerrank.com/challenges/30-abstract-classes/problem?isFullScreen=true
class MyBook < Book
attr_accessor :price
attr_accessor :author, :title
# Class Constructor
#
# Parameters:
# title - The book's title.
# author - The book's author.
# price - The book's price.
@see-why
see-why / SubArrayDivision.js
Created January 16, 2022 17:30
HackerRank SubArray Division Challenge
function birthday(s, d, m) {
// Write your code here
let count = 0;
s.map((item, index) => {
let sum = item;
for (let i=index+1; i < (index+m) ; i++ ){
if (i < s.length){
sum += s[i];
}
}
@see-why
see-why / DivisibleSumPairs.js
Created January 16, 2022 18:56
HackerRank Divisible Sum Pairs challenge
//https://www.hackerrank.com/challenges/divisible-sum-pairs/problem?isFullScreen=true&h_r=next-challenge&h_v=zen
function divisibleSumPairs(n, k, ar) {
// Write your code here
let count = 0;
let sum = 0;
ar.map((item, index) => {
for (let i=index + 1; i < ar.length; i++){
sum = item + ar[i] ;
if( sum % k == 0){
@see-why
see-why / LinkedList.js
Created January 17, 2022 08:54
HackerRank Day 15 of 30 days of code challenge
//https://www.hackerrank.com/challenges/30-linked-list/problem?isFullScreen=true
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
@see-why
see-why / SalesByMarch.js
Created January 17, 2022 11:50
Interview Preparation Kit Warm Up Challenges...Sales By March
//https://www.hackerrank.com/challenges/sock-merchant/problem?isFullScreen=true
function sockMerchant(n, ar) {
// Write your code here
let count = 0;
let checked_numbers = [];
for (let item of ar){
if (checked_numbers.includes(item) == false){
let frequency = 0;
ar.forEach((value) => value == item && frequency++);
@see-why
see-why / MigratoryBirds.js
Created January 18, 2022 08:17
HackerRank Migratory Bird Challenge
//https://www.hackerrank.com/challenges/migratory-birds/problem?isFullScreen=true
function migratoryBirds(arr) {
// Write your code here
let count = 0;
let value = 0;
for(let item=1; item<=5; item++){
let frequency = 0;
arr.forEach((val) => val == item && frequency++)
if (frequency > count || (frequency == count && item < value)){