Technical Interview Preparation
ACM Chapter at CSUF
Quick Resume Tips
The Process
Next Steps
What is a Behavioral Interview?
What is a Technical Interview?
Technical Interview Process
Good Questions to Ask…
2. Verify your assumptions
3. Check edge cases
4. Periodically check your work with your interviewer
Determine whether or not a string is a palindrome.
Examples:
Example Interview
“hello” -> false “racecar” -> true “a” -> true “mom” -> true “raincoat” -> false “tacocat” -> true |
def isPalindrome(S): i = 0; j = len(S) - 1 while i <= j: if S[i] != S[j]: return False i += 1; j -= 1 return True |
Example Interview: Solution
Mock Interview Exercise
Problem 1: Missing Number
Given a sorted array nums containing distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
Input: [0,1,2,3,5]
Output: 4
Missing Number: Solution
def missingNumber(nums):
expected = 0
for i in nums:
if i != expected: return expected
expected += 1
return expected
Problem 2: Sum Evens
Given an array of numbers, sum all the even numbers in the array
Input: [1,2,3,5,6,10]
Output: (2 + 6 + 10) = 18
Sum of Even: Solution
def sumOfEven(nums):
sum = 0
for num in nums:
if num % 2 == 0:
sum += num
return sum
Problem 3 (HARD): Find Mode of Array
Given an array of numbers, find the mode of the array. The mode of the array is the number that occurs the most in the array.
Input: [5,6,1,2,3,5,3,3,10]
Output: 3
Array Mode: Naive Solution
def majorityElement(nums):
if not len(nums): return None
res = 0
val = 0
for n in nums:
store = 0
for x in nums:
if x == n:
store += 1
if store > res:
res = store
val = n
return val
Array Mode: Optimal Solution
def majorityElement(nums):
freq_map = {}
freq = 0
val = 0
for x in nums:
freq_map[x] = freq_map.get(x, 0) + 1
temp = freq_map[x]
if temp > freq:
freq = temp
val = x
return val
NEXT WORKSHOP: 03/08/23
(Trees)