CRACKING THE CODING INTERVIEW

Download Report

Transcript CRACKING THE CODING INTERVIEW

CRACKING THE CODING
INTERVIEW
Nitish Upreti
Nitish Upreti
@nitish
http://niti.sh/
Feedback Please !
( I am a Data Junkie… )
www.meet.ps
Why this Talk?
Why should you care ?
For the love of Computer Science
…
Building Amazing Products
Working
People…
with
the
best
of
Have an Impact !
Head start in Building your career …
Money & Free Food ?
Start Your own Company ?
Working for the Top
Technology Companies.
(Computer Science-Engineering majors are
most pampered and well paid…)
Easy : Just clear the coding
interview ?
Or Not ?
Some of us are scared !
How does the interview work?
What do they judge me on?
Do’s / Don’ts
Are these interviews fair?
Can you judge someone in few hours or
a day?
Think of Interviews as acing SATs /
GREs
…
(Whether they are any good is debatable!)
GAME
1. Study
2. Finish
3.
Get
PLAN
:
all my subjects well.
all Assignments/Projects.
an
awesome
GPA.
There is more to it …
Would you practice for a Sprint by
running marathons each day?
Take Away….
Preparations
Matter!
“Sweat now so you don't bleed
later.”
Lets get cracking!
Before the Interview…
How to get interviews at the first
place?
• Career fairs.
• Referrals from friends and seniors. (Almost
guarantees an interview)
• Be active on LinkedIn.
• Visit Hackathons.
• Start competing on HackerRank / TopCoder.
• Email cto_first_name / ceo_first_name @startup
Quick Preliminaries
• Perfect your resume
(No spelling mistakes / grammar errors)
ACM provides help!
• Prepare Behavioral Questions
Judging You On :
What you learned?
Most Challenging Problems ?
Most Interesting Problem ?
Hardest Bug ?
Enjoyed Most ?
Conflict with Teammates ?
So I got the call 
How does the Interview Process
work
?
( At least for the Popular Ones …. )
Interview Process
• Starts with an Email Conversation.
• Scheduling day/time for Phone or Campus
screening
• Internships : Usually 2 telephonic rounds.
• Full time : 5-7 interviews
• PSU Microsoft experience is an exception when it
comes to interviews. (Why?)
• You are notified in a couple of weeks.
• Details are in the Book!
How should I prepare ?
White
Board
Coding….
(Without the cozy compiler : Marathon and
Sprint metaphor again!)
What should I prepare?
Almost Comprehensive List
…
• Elementary DS :
–
–
–
–
•
•
•
•
•
Arrays, Stacks & Queues
Linked Lists
Trees ( Binary Trees, Binary Search Trees)
Hash Tables
Asymptotic Analysis
Sorting with their Runtimes.
Recursion !
String Problems
Good to know : TRIE and Priority Queue (
BinaryHeap)
Advanced
•
•
•
•
•
Divide and Conquer Algorithms.
Greedy Algorithms
Dynamic Programming
Graph Algorithms
Some Design Problems
During the Interview …
Key things to keep in mind
• All questions are language independent.
• Start Talking ( Interviewers nudge you towards
the right direction )
• Think before you start / Don’t rush.
• Propose a variety of solutions idea before
settling on coding a particular idea.
• Sound Enthusiastic !
• Ask questions in the end : How do you work?
What do you work on?
Make Or Break it !
• Think about Corner cases.
• Test your code once your done.
• Be Space / Time Efficient.
( Distinguishes a Good Vs Bad Interview)
Lets dissect a real interview
question !
Given a set of integers, is
there a subset of size k
whose
sum
is
zero?
Array = { 3, 9, 1 , 6 , 0, 2 }
Sum = 8
I am STUMPED !
Let us start talking ….
Brute Force Anyone ?
Find all the possible sums and if the
given sum is one of them, we have a
solution!
Brute Force could be a good start.
Don’t code it yet !
Runtime Analysis ?
O(
2
N )
Can
we
do
better?
At Google’s scale there will be
Billion Numbers !
Sorting + Binary Search ?
O (N log N) + O (log N)
Can we do Even Better?
How about a Hash Table
Solution?
First Passes :
Create a Map (HashMap)
Array = { 3, 9, 1 , 6 , 0, 2 }
Hash = { (3,T) (9,T) (1,T) (6,T)
(0,T)(2,T) }
Scan through the keys & look for
remainder.
Corner Case : Duplicate Elements !
Array = { 3, 9, 1 , 6 , 0, 4 }
Hash = { (3,T) (9,T) (1,T) (6,T)
(0,T)(4,T) }
Solution : Store Count !
Complexity ?
Time : O ( N )
Space : O ( N )
MUST READ Books …
Before I Finish …
GSoC 2014 Is On!
Feedback / Questions ?