Algo 1 Flashcards
String Reversal
Solution 1. JS methods to convert string into array and vs
Solution 2. For every letter - build from empty string
Solution 3. Use reduce method on an array to build from empty string.
Palindromes
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
Solution 1 - reverse and compare
Solution 2 - compare first to last, second to second to last, etc
Reverse Integer
LeetCode - Reverse Integer:
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
solution 1 - javascript methods to convert string into array and vs
max chars
given a string return a character that is most commonly used in a string
make an object with keys as letters and values as number of times they occur
fizzbuzz
Print integers 1 to N, but print “Fizz” if an integer is divisible by 3, “Buzz” if an integer is divisible by 5, and “FizzBuzz” if an integer is divisible by both 3 and 5, if not a number return Not a number, return same number if neither.
Array Chunking
Given an array and a chunk size, divide the array into many sub-arrays where each sub-array has the specified length.
chunk solution 1
chunk solution 2: while loop, slice, iterate index with size
anagrams
given 2 words, decide if anangrams
write pseudo code first
solution 1 - clean string, make a helper function for character map, return false if unequal amount of keys, compare characters in one string to another, return false if it’s unequal; return true if all checks out
solution 2 - sort
Sentence capitalization
solution 1: uppercase by slicing the first letter of the word
solution 2: if index to the left is an empty string, capitalize at the index
return sentence.split(‘ ‘).map(word => word.charAt(0).toUpperCase() + word.substring(1)).join(‘ ‘)
the step question
for positive number N
‘#__’
‘##_’
‘###’
solution 1: draw the diagram
solution 2: use recursion
pyramid problem
draw the diagram
solution 1:
solution 2:
Get the Vowels
Iterative Solution - which array method can I use?
Regex Solution
General Matrix Spirals
draw the diagram
draw the steps
solution
runtime complexity
define
types
classify each problem solved
big o notation
Describes the performance of an algorithm. How much processing power/time is required to run your algorithm if we double the inputs?
PROCESSED - Coding Interview Algorithms 1
fibonacci series
Given a number N return the index value of the Fibonacci sequence
iterative
recursive
without memoization
with memoization
https://stackoverflow.com/questions/8845154/how-does-the-fibonacci-recursive-function-work
memoization
diagram
generic memoization function
memoized fibonacci