This file contains hidden or 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
| /*================ | |
| * Types | |
| ================*/ | |
| type Pizza = { | |
| name: string; | |
| toppings: string[]; | |
| }; | |
| type PizzaName = "Pepperoni" | "Meat Lovers" | "Veggie Lovers"; | |
| type Size = "small" | "medium" | "large"; |
This file contains hidden or 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
| /* eslint-disable */ | |
| const ALL_PACKAGES = { | |
| 'package-1': ['package-2', 'package-3'], | |
| 'package-2': [], | |
| 'package-3': [], | |
| 'package-4': ['package-3', 'package-6'], | |
| 'package-5': ['package-6'], | |
| 'package-6': [], | |
| }; |
This file contains hidden or 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
| # Python code to find the | |
| # repeated elements in the | |
| # array where every other | |
| # is present once | |
| # Function to find duplicate | |
| def findDuplicate(arr): | |
| # Find the intersection | |
| # point of the slow and fast. |
This file contains hidden or 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
| # Python code to find the | |
| # repeated elements in the | |
| # array where every other | |
| # is present once | |
| # Function to find duplicate | |
| def findDuplicate(arr): | |
| # Find the intersection | |
| # point of the slow and fast. |
This file contains hidden or 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
| const letters = (words, letter) => { | |
| const newWords = words; | |
| newWords[letter] = newWords[letter] ? newWords[letter] + 1 : 1; | |
| return newWords; | |
| }; | |
| function palindromeRearranging2(inputArray) { | |
| const words = inputArray.split('').reduce(letters, {}); | |
| const values = Object.values(words); | |
| let ban = false; |
This file contains hidden or 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
| function arrayChange(inputArray) { | |
| console.log(inputArray); | |
| let counter = 0; | |
| let itemOne = inputArray[0]; | |
| for (let i = 1; i < inputArray.length; i += 1) { | |
| const itemTwo = inputArray[i]; | |
| if (itemOne === itemTwo) { | |
| itemOne = itemTwo + 1; | |
| counter += 1; | |
| } else if (itemTwo > itemOne) { |
This file contains hidden or 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
| function areSimilar(a, b) { | |
| const valueLen = a.length; | |
| const otherLen = b.length; | |
| const newB = b; | |
| let errors = 0; | |
| let swapFirst = -1; | |
| let swapSecond = -1; | |
| if (valueLen !== otherLen) return false; | |
| for (let i = 0; i < valueLen; i += 1) { | |
| const itemOne = a[i]; |
This file contains hidden or 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
| function addBorder(picture) { | |
| const width = picture[0].length + 2; | |
| const asterintics = '*'.repeat(width); | |
| return [ | |
| asterintics, | |
| ...picture.map(line => `*${line}*`), | |
| asterintics, | |
| ]; | |
| } | |
| module.exports = addBorder; |
This file contains hidden or 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
| // compare the arrays item by item and return the concatenated result | |
| function merge(left, right) { | |
| const result = []; | |
| let indexLeft = 0; | |
| let indexRight = 0; | |
| while (indexLeft < left.length && indexRight < right.length) { | |
| if (left[indexLeft] < right[indexRight]) { | |
| result.push(left[indexLeft]); | |
| indexLeft += 1; |
This file contains hidden or 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
| // Write a function that accepts two strings | |
| // and returns true if they have the same letters | |
| // | |
| // e.g. "mono" and "moon", but not "ret" and "tree" | |
| // divide string in letters count letters verify same count each word | |
| function getLetterCount(word) { | |
| const letters = word.split(''); |
NewerOlder