Skip to content

Instantly share code, notes, and snippets.

// Do two given strings form an anagram?
// Possible solution should not be a higher Big O notation than O(n).
// Evaluation is case insensitive.
/**
* @param str1 | String
* @param str2 | String
* @return Boolean
*/
const isItAnAnagram = (str1, str2) => {
@deemaxx
deemaxx / numPairEqualSum.js
Last active April 25, 2020 16:33
Algorythms
// Given an array of numbers as an argument, and a number as a second argument
// find two numbers in the array that adds up the sum.
// const array = [2, 8, -19, 33, 923];
// const sum = 904;
// returns [-19, 923]
/**
* Function that searches for a pair of numbers which add up to the given sum
* @param array | Array<number>
* @param sum | number
@deemaxx
deemaxx / reverseString.js
Last active April 27, 2020 00:22
Reverse a String with different methods.
// Reverse a string with the Array.reverse() method, recursive method, the for loop method, or the ES6+ method.
const revString = 'olraC si eman ym iH'
/**
* Reversing a string with a for loop
* @param str | string
* @returns | string
*/
function forLoopStringReversal(str) {
let newStr = '';
@deemaxx
deemaxx / mergeSort.js
Last active April 30, 2020 12:41
Merge and sort 1 or more arrays
const array = [0, 1, 3, 4, 31, 2, 4, 6, 7, 10, 23, 30];
/**
* Merge Sort is a divide and conquer algorithm. It divides input array in two halves,
* calls itself for the two halves and then merges the two sorted halves.
* time complexity: O(nLogn)
* space complexity: O(n)
* @param arr | Array<number>
* @return Array<number>
*/
@deemaxx
deemaxx / twoSum.ts
Last active May 11, 2020 12:34
Find 2 numbers in an array input that up add to a target number and return their indices
/**
* Given an array of integers, return indices of the two numbers such that they add up to a specific target.
* You may assume that each input would have exactly one solution, and you may not use the same element twice.
*
* @param {Array<number>} nums
* @param {number} target
* @return {Array<number>}
*/
const nums: Array<number> = [3, 5, 8, 15, 22, 78]
const target: number = 30
@deemaxx
deemaxx / input.scss
Created July 7, 2022 19:23
Generated by SassMeister.com.
@mixin spacing {
--spacing-none: 0;
--spacing-extra-small: 4px;
--spacing-small: 8px;
--spacing-medium: 12px;
--spacing-large: 16px;
--spacing-extra-large: 20px;
--spacing-extra-extra-large: 32px;
--spacing-extra-extra-extra-large: 40px;
}
@deemaxx
deemaxx / input.scss
Created July 7, 2022 19:39
Generated by SassMeister.com.
@mixin spacing {
--spacing-none: 0;
--spacing-extra-small: 4px;
--spacing-small: 8px;
--spacing-medium: 12px;
--spacing-large: 16px;
--spacing-extra-large: 20px;
--spacing-extra-extra-large: 32px;
--spacing-extra-extra-extra-large: 40px;
}