Algo 1 Flashcards

1
Q

String Reversal

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Palindromes

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Reverse Integer

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

max chars

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

fizzbuzz

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Array Chunking

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

anagrams

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Sentence capitalization

A

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(‘ ‘)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

the step question

A

for positive number N
‘#__’
‘##_’
‘###’

solution 1: draw the diagram
solution 2: use recursion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

pyramid problem

A

draw the diagram
solution 1:
solution 2:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Get the Vowels

A

Iterative Solution - which array method can I use?

Regex Solution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

General Matrix Spirals

A

draw the diagram
draw the steps
solution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

runtime complexity

define
types
classify each problem solved
big o notation

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

fibonacci series

Given a number N return the index value of the Fibonacci sequence

A

iterative
recursive
without memoization
with memoization

https://stackoverflow.com/questions/8845154/how-does-the-fibonacci-recursive-function-work

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

memoization

A

diagram
generic memoization function
memoized fibonacci

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

data structure

A

define

draw

17
Q

queue

A

draw

equivalent in array