One Pager Cheat Sheet
- Emphasizing problem solving and analytical skills as foundational to programming interviews, this AlgoDaily tutorial helps candidates by visualizing problems and solutions and offering a road map through
basic mathematics
topics likeprobability
,combination
,permutation
,ratios
, andpercentage
, noting that interviewers may overlook minor syntax hiccups but not weak reasoning. - An analytical reasoning puzzle (with a brief visualization) asks for Samuel's final
direction
after he starts walking towards east, then turns left, turns left again at the bus stop, and finally turns right after 1 km. - Since
10 × 2 = 20
slices
and eachpizza
has4
slices
, they should order5
pizzas (20 ÷ 4 = 5
). - Lana has 2 bags of 2 marbles (
2*2=4
) and Markus has 2 bags of 3 marbles (2*3=6
), so Markus has 2 more marbles (difference = 6-4 = 2
). - Kate divides the portrait into
6
equal parts, so each part represents1/6
of the whole. - Rolling a fair die labeled
1
–6
for12
independent trials, the expected number of1
s (theexpected value
in abinomial
model) is12 × (1/6) = 2
, not twelve times, because each roll has a 1-in-6 probability of landing on1
. - With equal bags (
3
each), John has12 ÷ 3 = 4
marbles per bag and William has18 ÷ 3 = 6
, so William has 2 more marbles per bag. - Of
100
skates,60%
are for boys, leaving40
;20%
of the remainder go to elders (8
), so skates for girls =32
. - To find the heavier ball among
8
with only2
uses of amechanical balance
, split into three groups (3-3-2
), first weigh3
vs3
: if one side is heavier, the ball is among those3
—weigh any2
to locate it; if they balance, the ball is in the remaining2
—weigh them to identify the heavier ball. - In permutations—arrangements where order matters—the count is given by the
factorial
n!
, with partial arrangementsnPr = n!/(n-r)!
, so for A, B, C there are3! = 6
total and3P2 = 6
two-letter arrangements, noting1! = 1
and0! = 1
. - With seats labeled
positions 1–6
in a single row, E and F are sitting in center (positions 3
and4
), A and B are at the ends (positions 6
and1
respectively, sinceC
is immediately left ofA
atposition 5
), leavingD
atposition 2
, so the person at the right of B is D. - Because 'CHAIR' has 5 distinct letters, the number of words that can be formed (i.e.,
permutations
) is5! = 120
. - By counting the distinct arrangements of the letters in "SWIMMING" with repeats (
I
andM
each twice) using thepermutation
formula8!/(2!*2!)
, the total number of words is 10080. - Count permutations of "REMAINS" with the vowels in odd positions by placing the 3 vowels in the 4 odd slots in
4P3 = 24
ways and arranging the 4 consonants in the remaining slots in4! = 24
ways, giving 24 × 24 = 576 total permutations. - Arrange the
consonants
M, K, R, R first, giving distinct permutations4!/2! = 12
, then use the gap (slot) method to select2
of5
gaps
and order A and E inC(5,2) * 2! = 20
ways, yielding 240 arrangements with no vowels adjacent. - A combination is a selection where order is not important, counted by
nCr = n! / [r! * (n-r)!]
, with examples3C2 = 3
(AB, BC, CA) and3C3 = 1
, and key identitiesnCn = 1
,nC0 = 1
,nC1 = n
, and symmetrynCr = nC(n-r)
. - Choose 1 man in
3C1 = 3
ways and choose 3 women in4C3 = 4
ways usingnCk = n!/(k!(n-k)!)
, so the total number of committees is 12. - From 5 black and 3 red balls, the number of 5-ball selections with at least 3 black balls is computed by summing
combinations
5C3*3C2 + 5C4*3C1 + 5C5*3C0
, yielding 46 ways. - Since a 4-digit number divisible by 10 must have
0
in theunits place
, we choose thetens
,hundreds
, andthousands
digits from{3,5,7,8,9}
in5×4×3
ways (equivalently5P3
or5C1·4C1·3C1
), yielding 60 possible numbers. - The total number of handshakes is 105 because each handshake corresponds to an
unordered pair
of distinct people, so we count each pair once using thecombination
15C2
=15*14/2
, which avoids double-counting. - Probability is a branch of mathematics that measures the likelihood (0 to 1) of a
random event
, illustrated by coin toss outcomes (one toss:(H, T)
; two coins:(H,H)
,(H,T)
,(T,T)
), and calculated using the formulaP(E) = Number of favorable outcomes / Total number of outcomes
. - With 6 pillows (3 red, 2 yellow, 1 blue), the probability of picking a yellow pillow is
2/6
=1/3
. - From 1000 picks (300 blue, 200 red, 450 green, 50 orange), the probability of picking a green bottle is
P(green) = 450/1000 = 0.45
, and the likely number of green bottles in a 100-bottle container is 45. - The probability of getting 3 when
rolling a fair die
is1/6
, because thesample space
{1,2,3,4,5,6}
has six outcomes and only one favorable event{3}
. - In a standard 52-card deck, the probability of drawing a face card (Jack, Queen, or King) is
12/52 = 3/13
, since there are 12 favorable outcomes (3 ranks × 4 suits) out of 52 total outcomes. - The probability that a randomly drawn ticket from 1–30 is a multiple of 3 or 5 is 14/30 = 7/15, computed via
inclusion–exclusion
by countingmultiples of 3
(10) andmultiples of 5
(6) and subtractingmultiples of 15
(2). - In a leap year (
366
days), after52
full weeks there are2
leftover consecutive days that can be any of seven weekday pairs, and since Monday occurs in two of these pairs, the probability of getting 53 Mondays is2/7
. - Assuming
independence
, the probability they contradict each other is 35%, computed asP = P(A truth)P(B lie) + P(A lie)P(B truth) = 0.75*0.2 + 0.25*0.8 = 0.35
. - Rolling two fair dice yields 36 equally likely outcomes in the
sample space
; applying theinclusion–exclusion principle
to event “at least one die is 4” (11 outcomes) and event “sum is 7” (6 outcomes) with 2 in their intersection givesP(E ∪ F)
= 15/36 = 5/12.