Skip to content

Instantly share code, notes, and snippets.

View Amaka202's full-sized avatar
🌏
Working from home

Chiamaka Umeh Amaka202

🌏
Working from home
View GitHub Profile
@Amaka202
Amaka202 / algoFridaysWeek5.js
Created May 8, 2021 14:44
Algorithms Friday Solution for week 5
// A school has two classes A and B. Each class has the ages of its students in
// a sorted list.
// The school decides to join both classes and needs you to help them write a function
// that merges both lists into one such that the students' ages still remain
// sorted in an increasing order
// PS: Do not use in buit sort function
@Amaka202
Amaka202 / algoFridaysWeek2.js
Last active May 8, 2021 14:33
Algorithms Friday Week 2 Solution
// Given an array nums, and a value val, write a function to remove
// all instances of val from the array and return the new length
const removeValInstances = (arr, val) => {
if(!arr) return 0;
if(!Array.isArray(arr)) return 0;
if(!val) return arr.length;
let newArrLength = 0;
@Amaka202
Amaka202 / algoFridaysWeek1.js
Last active April 12, 2021 09:42
Algorithm Fridays Week 1
// Given a sorted array nums, write a function to remove the
// duplicates from the array such that each element appears
// only once. Your function should return the new length
const removeDuplicateArrayElements = (nums) => {
const noDuplicatesArray = [];
for(let i = 0; i < nums.length; i++){
//compare adjacent elements of the array and check if they
//are the same since the array is sorted already, skip if true.