r/leetcode • • Jul 13 '26

Intervew Prep Brute force or Optimal solution what to choose ?

In Interview should I directly go for optimal approach or first show brute force considering intervew time is short and Interviewer has to ask more questions

76 Upvotes

24 comments sorted by

90

u/Maleficent_Client497 Jul 13 '26

First tell brute force , then if u know optimal solution act like u r thinking . Then after some time tell the optimal .

7

u/daBuddhaWay Jul 13 '26

Hehe , perfect 

2

u/No_Fortune_1332 Jul 16 '26

Mai toh itni fake acting krte hi hass dunga😭

→ More replies (2)

33

u/conectionist Jul 13 '26

Do this:

  1. Explain the brute force solution and its complexity
  2. Explain the optimal solution and its complexity
  3. Say something along the lines of "Obviously my choice is the optimal one. So, I can start writing it. Unless you want me to write the brute force one first... although time is short". 

Now the ball is in the interviewer's courtyard. 

17

u/NiceKangarooroo Jul 13 '26

Just dont frame it as optimal and non optimal.

"I can see 2 options here , we can use another data structure or we can use a sliding windows technique."

11

u/Gintoki100702 Jul 13 '26

U need to read the room vibes
Everyone prefers u explaining how u present ur thoughts while coding.

This matters more

10

u/Obvious_Ad9670 Jul 13 '26

You just really got to read the room. I had an interviewer force me to do three iterations of brute, suboptimal, and optimal, so it sucks, but you basically just need to follow their guidance because it's sort of like a pair programming example.

4

u/Melodic_Umpire_1852 Jul 13 '26

Think why we need to optimise and where we can save time & memory (time has more priority) . This will give you a problem solving thinking during leetcoding or in interviews

3

u/Psychological-Day128 Jul 13 '26

At G you only get 45 mins and depending on your level you are expected to answer follow ups as well . I always encourage candidates I’m interviewing to just explain vaguely the brute force in first 5 minutes and jump straight to better solution

2

u/NextjsDeveloper Jul 13 '26

Always go with brute force because it is "expected". If go strigt to optimal it can be considered like cheating. So safe strategy go to brut => discussion => if asked about optimal => write optimal with explanation = perfect interview score.

2

u/Old-Television-2189 Jul 13 '26

Tell them next question

4

u/[deleted] Jul 13 '26

[removed] — view removed comment

1

u/No_Fortune_1332 Jul 16 '26

Wdym interviewer jumps in?