#!process Amazon final
1 messages · Page 1 of 1 (latest)
LC
Wanted k most frequent strings but in lexicographical order
I didn’t give optimal solution
did interviewer give hints to optimal
I gave O(n log n) but wanted O(n log k)
Yeah he gave me a lot of hints to try to get the optimal solution
But u didn’t get it?
He basically told me what to do at the end
How’d behavioral go
nah you might be fine bro
I think that’s offer tbh
He wasn’t satisfied
Heaps?
Not at all
Uh
Yeah heaps
Then idk
Did you use heaps
How’d u know he wasn’t satisfied
Ah
Did bro want quick select or some shit
What’s that solution
Used min heap, pop if new most frequent comes up
Quick select wouldn't be log
Wait so first big top k
And then sort right?
Idk
And then sort output
Yeah I should’ve done that
Cause output is bounded to length k
No
Ah
I gave n log n
Ah
So I’m cooked
Damn a one liner difference too
good luck man
The problem was that I thought of heaping everything
Ahh
Bro is not cooked
And then getting the k most frequent
Yea heap part is n log k
But that’s O(n) he was like it’s not O(n)
Sorting output would be k log k
I didn’t even get the optimal solution man
And i went in the wrong direction at first
If k << n then yea n log k final complexity
Yeah my dude straight told me what optimal algo was
I’m just fucked
At the end, but bro had to help
I also made a wrong solution at first, like not even non optimal but just wrong
He pointed it out then asked if I knew a specific algo
Then I said yeah and wrote a new solution
where are you based, canada or us?
US
🇺🇸 on top
one of my friends did behavioural a few weeks ago and he said they asked him about his projects instead of standard behavioural
in canada tho
i also have amazon final coming up
Eiehter way u shud be fine
can i introduce projects that were not on my resume when applying? 😭
iterate through list counting frequency's then putting it into a max heap and popping k times?
yeah thats nlogk
thought it was k log n
n because u pass through the entire list of n elements
I was thinking
Counter(words)
max heap with the tuples or whatever
then pop k times
heapify can get O(n)
Uhm not sure if thays the case then ig no issues but i think its nlogn
this is what leetcode said for my code
class Solution:
def topKFrequent(self, words: List[str], k: int) -> List[str]:
word_count = defaultdict(int)
#Intialize all words into frequency dictionary
for word in words:
word_count[word] += 1
#Make a heap that sorts the words primarily by frequency and breaks ties lexicographically
heap = [(-count, word) for word, count in word_count.items()]
heapq.heapify(heap)
result = []
#Return k top elements from the heap
for _ in range(k):
result.append(heapq.heappop(heap)[1])
return result
my code ^
This video explains the build heap algorithm with example dry run.In this problem, given an array, we are required to build a heap.I have shown all the observations and intuition needed for solving the problem.I have shown all the prerequisite concepts required to solve the problem as well using examples.We can use the heapify algorithm to do th...
I said the same thing in my zon interview, and the interviewer grilled me asking thtere are no comparative sorting algos that take less than nlogn
takes log n time to heappop and we do it k times k log n
heaps aren't fully sorted
dont wanna be a downer but i got optimal, nearly coded it up in time but not fully and get rej so....
i can 2nd this, i solved it using max heap and got the same time complexity, nlogk
I feel like if you did bad on lp and still got an offer you didn’t do as bad as you think
when interviewer told me my story made him feel uncomfortable I can confidently said it was not smooth sailing
@warm niche @broken herald @wicked drift
I remember you, what did you say again
To make him say that
oh hell nah
bro what did you say
whazzup
💀
wtf did u say
Getting an offer from that is kinda crazy
we need the story
Hell nah if this mf got an offer I better
^
@broken herald inspiration
honesty maybe bc he saw I handle it well
This is crazy work
mipmaster speech when he gets zon offer will be legendary
Im actually probably cooked
Nah tell us what u said
it was literally like tell us a time when you under a time crunch
so I said I had to quickly finish my software engineering project the day before the code review or something
lowkey standard idk what went wrong
maybe it was a test to see if I would crack under pressure
nah youre not telling us something
ye
how did that make him unconfortable
whats going on
That’s literally it
I think he thought i procrastinated or something
But it was more like a bug
bro was this you
Last minute thag we had to fix
i cant tell since ur gmi now

“Yeah in my interview I talked about the alternate use cases for bananas “
Im just trying to give my boi some hope
how tf was ur interviewer uncomfortable from ur story of finishing work the day before
this seems more likely
idk believe what you wanna believe
congrats on offer eitherways dawg