Few hints about coding interview

# The story

“Could you please help to solve this coding problem?”, I shared my screen.

We started with a simple binary search problem.

“Sure let me take a look”. he answered.

After 5 mins.

“I want to sort the array and then do a binary search, so let me write a sort function for this,” he said.

“Why not use array.sort()?” I asked.

“Am I allowed to use that built-in function?” He asked

“Yes, why not. please use it” I said.

After 20 mins. we started another problem. a variation of the “subset” backtracking problem.

“I am thinking of using the sliding window approach, but it seems not to solve all the cases”. he said

“Why not backtracking? do you think this is a standard subset problem?” I was giving him this hint because during the interview I do believe he has enough DSA knowledge.

“I thought about it. but I was worried that it may not be fast enough” he said.

“But the maximum input size is 20” I said.

“Okay, thanks, then backtracking is possible. let me finish the code”.

…

Above stories happened multiple times. that’s why I want to share with you this post.

Btw, in the end, I gave good feedback to my client. even though he has not come out with a perfect answer by returning “one time accepted leetcode”.

If the grasp of Data Structures and Algorithms is strong, I am satisfied with it.

In case your interviewers are expecting more or If you not sure how to find the “DSA pattern”. hope below could help you.

# Know the input size

<20: O(N!)

< 100: O(N³)

< 1000: O(N²)

<10K: N*Log(N)

10K: O(N)

And if you are already familiar with some leet code patterns:

Mono-stack: O(N)

BFS, DFS: O(V+E)

Pre-sum: O(N)

Kedane: O(N)

Sorting: O(N*Log(N))

Binary search: Log(N)

Heap: (K*Log(N))

Sliding window: O(N)

Divide and conquer: O(N*log(K))

2 pointers: O(N)

DP: Between O(N) to O(N²)…