How to standout in a DSA Interview ? | Important tips to crack DSA Assessment Rounds | @SCALER

SCALER
8 Apr 202413:40

Summary

TLDRIn this informative session, Harid Gupta from Soft Engineered discusses the best practices for tackling Data Structures and Algorithms (DSA) interviews. He emphasizes the importance of understanding the problem, starting with brute force solutions, and then optimizing them. Gupta highlights the need for clear communication of your approach, clean and understandable code, and thorough testing. Tips for preparation include practicing on a text editor, mock interviews, and being receptive to interviewer hints. The session aims to equip viewers with strategies to excel in DSA interviews.

Takeaways

  • 📚 Importance of DSA: DSA rounds are crucial in the hiring process to test candidates' coding and problem-solving skills.
  • 🧐 Preparation Beyond Coding: Solving many problems helps clear online assessments, but more is needed for in-person interviews.
  • 🔍 Clarification First: Always clarify the problem and assumptions before diving into a solution to avoid misunderstandings.
  • 🔄 Start with Brute Force: If an optimal solution is not immediately clear, start with a brute force approach to demonstrate a base understanding.
  • 💡 Think Out Loud: Share your thought process with the interviewer to keep them engaged and understand your approach.
  • ⏱ Time Complexity: Always consider and state the time and space complexity of your solutions to show awareness of efficiency.
  • 🔄 Optimize: Be open to hints from the interviewer and optimize your solution based on feedback to show adaptability.
  • 💻 Code Quality: Write clean, readable code with meaningful variable names and comments to demonstrate good coding practices.
  • 📝 Dry Run: Test your code with examples and edge cases to ensure correctness and demonstrate thoroughness.
  • 📈 Practice Mock Interviews: Use mock interviews to practice explaining your approach and receiving feedback for improvement.
  • 🔑 Communication: Maintain open communication with the interviewer to understand their expectations and adjust your approach accordingly.

Q & A

  • What is the main topic of the video script?

    -The main topic of the video script is discussing the right way to tackle Data Structures and Algorithms (DSA) questions in interviews.

  • Who is the speaker in the video script?

    -The speaker in the video script is Harid Gupta, a mentor of Soft Engineered.

  • What is the purpose of the SC Master Class mentioned in the script?

    -The SC Master Class is designed to help individuals improve their DSA knowledge and skills with the guidance of industry-leading experts.

  • Why is it important to understand the problem before providing a solution in a DSA interview?

    -Understanding the problem is crucial because it helps to avoid misinterpretation, ensures the solution is relevant, and demonstrates the candidate's ability to work with ambiguity.

  • What is the difference between a DSA online assessment and a DSA interview?

    -An online assessment primarily checks if the code is fully optimal, functional, and passes test cases, while a DSA interview also evaluates the candidate's ability to explain their approach and write clean, readable code.

  • What are the steps suggested for tackling DSA questions in an interview?

    -The steps suggested are: 1) Clarification or disambiguation, 2) Brute force or suboptimal solutions, 3) Building an optimal solution, 4) Improving the solution, 5) Coding, and 6) Testing or dry run.

  • Why is it recommended to think out loud while solving a problem in an interview?

    -Thinking out loud allows the interviewers to follow the candidate's thought process, which is as important as the final solution itself.

  • What should be the time and space complexity of a solution in a DSA interview?

    -The solution should aim for optimal time and space complexity, which means minimizing both as much as possible while still solving the problem effectively.

  • How can one prepare for a DSA interview?

    -One can prepare by solving questions in a text editor, practicing explaining their approach, using mock interviews for feedback, and understanding the interviewer's expectations.

  • What is the importance of variable naming in coding during a DSA interview?

    -Meaningful variable names are important as they make the code easier to understand and show the candidate's attention to detail, but they should not be overly descriptive to save time.

  • Why is it important to test the code with edge cases during the interview?

    -Testing with edge cases helps to demonstrate the candidate's thoroughness and ability to handle various scenarios, which is a valuable skill in software engineering.

Outlines

00:00

📘 Interview Preparation for DSA Rounds

Harid Gupta, a mentor at Soft Engineered, introduces the video's focus on tackling DSA (Data Structures and Algorithms) interviews effectively. He emphasizes the importance of DSA rounds in the hiring process and distinguishes between online assessments and in-person interviews. Gupta suggests that while solving many problems is beneficial, additional strategies are necessary for interview success. He outlines the unique challenges of in-person interviews, such as explaining your approach and writing clean, understandable code, and the importance of recognizing and improving upon one's solutions during the interview.

05:01

🔍 Steps to Ace a DSA Interview

The video script outlines a structured approach to DSA interviews, beginning with clarification of the problem at hand. It advises candidates to take time to understand the question fully and to discuss any assumptions with the interviewer. The script then moves on to suggesting the consideration of brute force solutions as a starting point, with an emphasis on time efficiency. It encourages candidates to think out loud to demonstrate their thought process and to explain their approach clearly, including the time and space complexity of their solutions. The script also highlights the importance of improving solutions based on interviewer feedback and the final steps of coding, which should be quick and include clear comments, and concludes with a brief testing phase to ensure the code's correctness.

10:03

👨‍🏫 Practical Tips and Example for DSA Interview Success

The script provides practical tips for preparing for a DSA interview, recommending that candidates practice on a text editor to mimic the interview setting and to focus on explaining their approach and code. It suggests mock interviews for gaining experience and receiving feedback. An example problem is presented to demonstrate the discussed strategies: finding an element with more than one occurrence in an array. The example walks through clarification questions, a brute force solution, and the development of a more optimal solution using sorting or a frequency map. The script concludes by emphasizing the importance of communication with the interviewer and adapting to their expectations, reminding viewers that an interview is a discussion, not a battle.

Mindmap

Keywords

💡DSC questions

DSC stands for Data Structures and Coding, which refers to a set of problems related to computer science that test a candidate's ability to implement and understand data structures and algorithms. In the video, the speaker mentions having solved 500 DSC questions, indicating a deep practice in preparation for technical interviews. The speaker's confidence in cracking all the DC rounds in companies is based on this extensive preparation.

💡DC rounds

DC stands for Data Coding, which is a common term used to describe rounds in technical interviews that assess a candidate's knowledge and problem-solving ability in data structures and coding. The script emphasizes the importance of DC rounds in the hiring process and suggests that the speaker will discuss strategies to excel in these rounds.

💡Soft Engineered

Soft Engineered is mentioned as the mentor's affiliation, indicating a background in software engineering and a role in guiding and educating others in this field. The mentor's expertise is highlighted to lend credibility to the advice given in the video.

💡DSA

DSA stands for Data Structures and Algorithms, which is a fundamental area of computer science that involves the study of efficient organization, storage, and retrieval of data, as well as the development of algorithms to solve problems. The video's theme revolves around how to tackle DSA questions in interviews efficiently.

💡Online Assessment (OA)

An Online Assessment (OA) is a method used by companies to screen candidates' technical skills remotely. In the script, the difference between OAs and in-person interviews is discussed, highlighting that while both involve DSA questions, the strategies to excel in them differ, especially in terms of code readability and interaction with the interviewer.

💡Coding Interview

A coding interview is a part of the hiring process where candidates are required to write code and explain their approach to solving a problem. The script discusses expectations from candidates in a coding interview and provides steps to tackle coding questions effectively.

💡Clarification

Clarification in the context of the video refers to the initial step in the problem-solving process where a candidate ensures they fully understand the problem statement. The script emphasizes the importance of taking time to clarify ambiguities in the problem before attempting a solution.

💡Brute Force Solution

A Brute Force Solution is a straightforward approach to solving a problem, often not the most efficient but serves as a starting point. The script mentions this as a step where if an optimal solution isn't immediately apparent, one should propose a brute force solution and then look to optimize it.

💡Optimal Solution

An Optimal Solution is a solution that provides the best outcome in terms of time and space complexity. The video script discusses the importance of thinking of an optimal solution during an interview, as it demonstrates a candidate's ability to balance efficiency and effectiveness.

💡Pseudo Code

Pseudo Code is a high-level description of an algorithm that does not contain the strict syntax of a programming language but explains the steps in plain language. The script suggests using pseudo code as a way to explain one's approach to the interviewer.

💡Time and Space Complexity

Time and Space Complexity are measures of the efficiency of an algorithm, indicating how the execution time and memory usage scale with the size of the input data. The script advises candidates to always state the time and space complexity of their solutions to show their understanding of these efficiency factors.

💡Variable Naming

Variable Naming refers to the practice of assigning meaningful names to variables in code to improve readability and understanding. The script emphasizes the importance of using meaningful variable names instead of generic ones like 'x', 'y', 'z' to make the code more understandable.

💡Dry Run

A Dry Run is a practice of testing code with sample inputs to ensure it works as expected without writing the full test cases. The script advises candidates to perform a quick dry run to demonstrate their code's correctness and to adjust if any issues are found.

💡Mock Interviews

Mock Interviews are practice interviews conducted to help candidates prepare for real interviews. The script recommends using mock interviews as a way to get feedback and improve interview skills, especially in explaining approaches and coding under time constraints.

Highlights

Harid Gupta, a mentor at Soft Engineered, discusses the effective approach to tackle DSA questions in interviews.

The importance of DSA rounds in the hiring process and the expectations from candidates in coding interviews.

The difference between DSA online assessments and in-person interviews, emphasizing the need for code readability and explanation.

Clarification or disambiguation as the first step in tackling a DSA interview question.

The strategy to start with a brute force solution and then optimize it in the interview.

The necessity of thinking out loud during the interview to demonstrate the thought process.

The importance of stating time and space complexity of any solution proposed during the interview.

Improving solutions based on hints from the interviewer and demonstrating the ability to optimize.

Coding efficiently during the interview, with tips on commenting and variable naming for clarity.

The significance of a dry run to test the code on given inputs and edge cases.

Preparing for a DSA interview by solving questions in a text editor and practicing explanations.

The value of mock interviews for practice and receiving feedback on interview performance.

An example problem demonstration on finding an element with more than one occurrence in an array.

The process of clarification for the example problem, including handling negative numbers and sorted lists.

Exploring different approaches like sorting, frequency maps, and hash sets for the example problem.

Writing clean and efficient code for the example problem, with emphasis on variable naming and comments.

The final advice on maintaining communication with the interviewer to understand their expectations.

The conclusion summarizing the key points for excelling in DSA interviews and inviting further questions.

Transcripts

play00:04

I have solved 500 DSC questions I'm

play00:06

definitely going to crack all the DC

play00:08

rounds in all the companies

play00:11

right right well maybe you need

play00:15

something more hello everyone this is

play00:17

harid Gupta a mentor of soft engineered

play00:20

Google today I will be discussing with

play00:23

you what is the right way to tackle DSA

play00:25

cions in any interview but before we

play00:28

talk about that check out SC Master

play00:30

Class by industry leading experts only

play00:32

on scalers event page link is in the

play00:34

description below so today we are going

play00:37

to discuss how to answer any DSA problem

play00:40

in an interview efficiently DSA rounds

play00:42

are one of the most common and most

play00:44

important rounds in any company's hiring

play00:46

process DSA round or coding or problem

play00:49

solving or algorithms round many names

play00:52

similar expectations these rounds are

play00:55

meant to test your DC knowledge problem

play00:57

solving ability but not just that

play01:00

today we are going to discuss what are

play01:03

the expectations from a candidate in a

play01:05

coding interview we will discuss what is

play01:08

the right way to answer in your coding

play01:10

round and how to

play01:12

prepare I know many of you will say that

play01:15

they know how to prepare just do a lot

play01:17

of problems and yes that will help you

play01:20

improve your DSN knowledge and your

play01:22

coding skills this kind of preparation

play01:24

will help you clear the OA for the

play01:26

companies but to perform well in an

play01:28

in-person interview you'll need a bit

play01:30

more this is why often we see people who

play01:33

are very good at coding not doing so

play01:35

well in the interviews so how DSA OA is

play01:37

different than DSA interview some

play01:39

companies first take an online

play01:41

assessment round for DSA and then an

play01:43

interview even though both rounds are

play01:45

similar and the questions that are asked

play01:47

are mostly similar but the strategy to

play01:50

excel in these rounds are different the

play01:53

OA round or online assessment round just

play01:55

covers whether your code is fully

play01:57

optimal fully functional and passes the

play02:00

test cases very rarely it happens that

play02:02

someone is actually going to look at

play02:04

your code or actually going to read that

play02:06

code and check how readability is but in

play02:11

OA the problem is that there's not much

play02:12

room for errors but that's not the case

play02:15

with d interviews even if you're not

play02:17

very sure about some language construct

play02:20

you can mention to the interviewer that

play02:22

I don't remember the exact way this

play02:24

thing is implemented but you can tell

play02:26

them how it

play02:27

works what makes a DSA inter view

play02:30

slightly difficult or just different

play02:33

maybe is that you have to explain your

play02:36

approach and your code it's not just

play02:39

about having the right approach but also

play02:41

being able to explain your approach

play02:42

properly and writing the code that's

play02:45

clean readable and easily understandable

play02:49

here we are not running our code on some

play02:51

test cases so we have to check ourself

play02:54

if our code is correct if it's covering

play02:56

all the Hedge cases and it's the most

play02:58

optimal possible

play03:00

in many cases the interviewer might not

play03:02

tell you if your code is covering all

play03:04

edge cases or if the time and space

play03:06

complexity can be improve so you have to

play03:09

demonstrate the skills to realize if

play03:12

your solution is the most optimal or if

play03:15

it can be improved much like actual

play03:18

software engineering

play03:19

work so how should we tackle CS in a

play03:23

dcent interview follow these steps so

play03:26

step one clarification or disambiguation

play03:29

clarify the question first you have

play03:32

enough time so you can take a few

play03:33

minutes to understand the question

play03:35

properly a lot of times people panic and

play03:37

just start talking about an approach

play03:39

without actually understanding the

play03:41

problem take your time understand the

play03:43

problem if it's not clear maybe ask the

play03:46

interview for an example if it's not

play03:48

already provided in some cases the

play03:51

question is intentionally left ambiguous

play03:53

to evaluate the candidate's

play03:55

understanding of the problem and a part

play03:57

of expectations is to see if the

play04:00

candidate is able to work with

play04:02

ambiguity even if you're assuming

play04:04

something about the problem it's a good

play04:06

idea to First discuss with the

play04:08

interviewer your assumptions and ask if

play04:11

they have any comment on that step two

play04:14

brute force or suboptimal Solutions if

play04:17

you can't think of any optimal solution

play04:19

right away you can start with a Brute

play04:21

Force solution but don't waste a lot of

play04:23

time on that just mention what will be

play04:26

the Brute Force solution and provide the

play04:28

reason why you're thinking of doing

play04:30

something better like the solution you

play04:33

provided can have a exponential time

play04:34

complexity you can just mention the

play04:36

approach by saying that since the time

play04:39

complexity here is too high I will try

play04:41

to find a better solution or maybe

play04:43

optimize this one again time is crucial

play04:46

here so don't spend a lot of time here

play04:48

the only reason to do this is to show

play04:50

the interview that while you're thinking

play04:52

of a solution you do have one root Force

play04:54

solution in mind it also demonstrates

play04:57

that you are not just thinking about

play04:59

without solving a question but solving

play05:01

it optimally step three build a solution

play05:05

the next step is to think of a good

play05:07

optimal solution this is where your DSA

play05:10

skills will be needed you can take some

play05:13

time to think about the solution but a

play05:15

good idea is to think out loud as the

play05:18

interviewers are also interested in your

play05:20

thought process being mute for a long

play05:22

time will also take away their attention

play05:25

not what you want in an interview while

play05:27

thinking of a solution you can use an

play05:29

example to build your approach and

play05:32

explain your approach to the interviewer

play05:34

explaining your approach by running the

play05:36

steps on an example is a good way to

play05:38

keep the interview aligned with your

play05:40

thought process some candidates also

play05:42

prefer writing algorithm or steps or

play05:46

pseudo code to explain the solution this

play05:48

is a personal choice and depending on

play05:50

time and practice you can do it either

play05:52

way also always State the time and space

play05:55

complexity of any solution you're

play05:57

thinking of right away don't wait for

play06:00

the interviewer to ask that this shows

play06:03

that while building a solution you're

play06:05

keeping the time and space complexity in

play06:06

mind and trying to build an optimal

play06:08

solution step four improve your solution

play06:12

use

play06:13

hints if the provided solution isn't

play06:15

most optimal or if there's something

play06:18

wrong with the approach the interviewer

play06:21

might hint you towards that just

play06:23

remember that everything that's coming

play06:25

out of the interviewer's mouth is useful

play06:28

it could be a hint on how to optimize

play06:30

your solution or interviewer might be

play06:32

nudging you away from a bad approach so

play06:35

be open to hints and try to make good

play06:37

use of them a good idea is to only go to

play06:41

coding when the interviewer is satisfied

play06:43

if the interviewer hints you that they

play06:45

are satisfied only then move towards the

play06:47

coding in cases where the question might

play06:50

be a little too complicated or

play06:52

challenging even if you not able to

play06:54

complete the code the interviewer might

play06:56

still give you a good rating given that

play06:58

your approach was correct and you

play07:00

explained it properly step five coding

play07:04

now we talk about the favorite part of

play07:05

the candidates the code I generally keep

play07:08

around 30 to 40% of the total time for

play07:10

this part after you have formalized your

play07:13

approach coding should be quick while

play07:16

writing code keep talking about what

play07:18

each part of the code is doing adding

play07:21

some small comments here and there is a

play07:23

good idea but don't start writing the

play07:25

whole documentations as you have limited

play07:27

time keep the comments short short and

play07:30

crisp keep your code clean and easily

play07:33

readable make use of spacing new lines

play07:37

blocks properly to group and separate

play07:40

various parts of your code variable

play07:41

naming is another important thing try to

play07:44

avoid naming your variables with random

play07:46

words like x y z although using IG for

play07:51

Loop variables is fine we all do that

play07:53

for Meaningful data values it's a good

play07:56

idea to have some meaningful names that

play07:58

show what this variable is storing the

play08:01

names don't need to be too descriptive

play08:03

though as writing long descriptive names

play08:05

again and again also takes time also

play08:09

don't take too much time in variable

play08:11

name engineering they don't have to be

play08:13

perfect but just not random step six

play08:16

testing or dry run as a last step test

play08:19

your code dry run it on a given inputs

play08:22

first and try to do it quickly if the

play08:24

input is input example is not given to

play08:26

you you can create a small example and

play08:28

try to run it on that you don't need to

play08:31

write a lot of details just enough to

play08:33

demonstrate what you are doing also try

play08:36

testing your code on edge cases like

play08:38

empty array negative values zero sorted

play08:41

array reverse sorted array Etc whatever

play08:44

might be the case for the problem but

play08:46

again don't spend too much time on this

play08:49

part don't dedicate more than a few

play08:51

minutes to dry run try to do it quickly

play08:54

and in a way that interviewer also

play08:56

understands what you're trying to do if

play08:58

you see any problem fix fix that quickly

play09:00

in some cases you might not get enough

play09:02

time to dry run but that's fine too also

play09:06

don't go towards a dry run if your

play09:08

interviewer is trying to take you to a

play09:10

follow-up question or a different

play09:11

question because going to that follow-up

play09:14

question or next question is more

play09:16

important so now let's discuss how to

play09:19

prepare for a DSA interview you know for

play09:22

DSA and for coding you can do a lot of

play09:25

problems and you'll improve your DSA and

play09:27

coding skills but how to prepare for a

play09:28

DSA inter view I'll share a few

play09:31

tips try to solve a few questions on a

play09:34

text editor first not an ID a text

play09:36

editor okay try to mimic the interviewer

play09:39

setting maybe even talk as if you are in

play09:42

an interview and you're explaining your

play09:44

code to someone practice explaining your

play09:46

approach practice writing your approach

play09:49

and demonstrating as if you are

play09:50

explaining it to someone before running

play09:53

test cases in an ID try to First keep

play09:55

your code in a text editor look at it

play09:58

yourself and try try to find any

play10:00

problems or improvements in your code

play10:02

when you feel that's the best you can do

play10:04

then go for testing your code in an ID

play10:08

one of the best ways to practice is

play10:10

using mock interviews ask someone who

play10:13

has some experience conducting

play10:14

interviews to take your mock interview

play10:17

and then ask for their feedback ask what

play10:19

would be the rating if this was an

play10:21

actual interview and what would be the

play10:23

detailed feedback now we will

play10:25

demonstrate whatever we learned today

play10:28

with an example

play10:30

let us consider this question given an

play10:32

array find an element that has more than

play10:34

one occurrence that means we have to

play10:36

find an element that is

play10:38

repeated let's first go towards the

play10:40

clarifying questions the clarifying

play10:42

questions can here be can we have

play10:44

negative numbers can we have more than

play10:46

one number which has a frequency more

play10:48

than one and if that's the case which

play10:51

one to return is the list given to a

play10:54

sorted and if there are no repeated

play10:56

elements what to do what to return

play10:59

right after the clarification we'll try

play11:02

the Brute Force solution The Brute for

play11:04

solution here will be that for each

play11:06

element I'll check all the elements in

play11:08

the array and I'll find the same value

play11:10

with a different index if there's any

play11:13

such case I'll just return that number

play11:15

the time complexity for this solution is

play11:18

order of n Square because for each

play11:20

number I'm checking the whole array

play11:22

space complexity although will be order

play11:24

of fun because I'm not using any extra

play11:26

space here I know the solution is is

play11:29

most optimal as the time complexity is

play11:31

quadratic and I feel we can do better

play11:33

than

play11:34

that then we will build a solution I

play11:38

think we can sort the list and check if

play11:40

any two adjacent numbers are the same if

play11:42

that's true we say that element is

play11:44

repeated the time complexity for this

play11:47

algorithm will be order of n login as

play11:49

sorting algorithms take order of n login

play11:52

time plus order of end time for AR

play11:54

traversal so overall time complexity

play11:57

will be order of n log n space

play12:00

complexity here will be order of fun

play12:02

because we are not using any extra space

play12:04

another approach is frequency map what

play12:07

we can do is for each number we can we

play12:09

can maintain a frequency map and for

play12:11

each number we can maintain a count of

play12:13

how many times this number appears in

play12:16

the array if we find any number which

play12:19

has a frequency more than one we can

play12:21

return that number or we can also

play12:23

maintain a set of numbers we have seen

play12:25

so far and if we encounter a number that

play12:27

we have already seen which is done that

play12:30

right we can use a hash set or a hashmap

play12:33

here for quick checking so the time

play12:34

complexity here will be order of n since

play12:37

checking in a hash map or a hash set

play12:39

takes order of one time space complexity

play12:41

here will be order of n because we might

play12:44

need to store all the numbers we can

play12:46

also mention the space time tradeoff

play12:48

then we can write the code which will be

play12:50

straightforward here after we have

play12:52

clarified the approach so this is the

play12:54

code in the end one important thing to

play12:57

note is that every interviewer is

play12:59

different while some interviewers might

play13:01

be looking for an optimal approach

play13:03

others might be interested in how clean

play13:05

your code is a good idea is to keep

play13:07

communicating with your interviewer to

play13:09

understand what they are looking for

play13:11

remember an interview is supposed to be

play13:13

a discussion not a vior so that's all

play13:16

for today I hope I was able to help you

play13:19

on how to excel in DSA interviews and

play13:21

provide some useful information if you

play13:24

have any further doubts please put them

play13:25

in the comments below and we will be

play13:27

happy to answer make sure to like and

play13:29

share this video And subscribe to

play13:31

scalers YouTube channel for more such

play13:33

content all the

play13:38

best

Rate This

5.0 / 5 (0 votes)

Related Tags
DSA InterviewCoding SkillsProblem SolvingInterview TipsSoftware EngineeringOnline AssessmentAlgorithm OptimizationTechnical InterviewCareer GuidanceSkill Development