#!process zon final (im so cooked)

1 messages · Page 1 of 1 (latest)

wise yoke
#

did u just get it?

tawny relic
#

I just took it

wise yoke
#

oh howd it go

tawny relic
#

had 4 behavioral 1 technical

#

kinda choked one of the behaviorals gave a bad response

#

hoping that doesn't mess me up

crisp root
#

cad or usa?

tawny relic
#

usa

#

my interviewer was in cad for some reason tho

#

idk maybe it doesn't matter

green olive
#

how was the technical

livid crag
#

AWS?

floral grotto
#

lol I interviewed for CAN but my interviewer was in the us

ember trellis
#

do you remember your techincal question?

tawny relic
#

was this one

#

I got optimal solution after a hint or 2 but it took me a while to write it up so idk

#

@ember trellis

tawny relic
molten ferry
#

was ur interviewers name brad?

#

@tawny relic

tawny relic
molten ferry
#

i had the same leetcode question

steel forum
#

my friend also got the same

#

simple sorting/heap problem

tawny relic
#

I said the wrong time complexity tho

molten ferry
#

oh my interviewer said

steel forum
#

did u say nlogk

tawny relic
#

o(nm) i said o(n)

molten ferry
#

assume its srted

steel forum
#

ohh

tawny relic
molten ferry
#

oh

#

if we r assuming its sorted

#

its o(n) right

#

nvm its still nm

#

did u use a sliding window approach

tawny relic
#

idk i thought it would be o(n) where n is amount of entries

tawny relic
molten ferry
#

its n m cuz if n is the amount of like users and then m is the everage amount of pages each user visited

tawny relic
#

wouldn't it be o(n) if n is amount of entries

molten ferry
#

im ngl

tawny relic
#

since it would be like 3n

molten ferry
#

i think i said O(N)

#

but i think i was wrong

#

lmao

crisp root
molten ferry
#

u guys used a heap?

#

i just stored it in a hashmap instead

#

cuz looping through the hashmap at the end is another O(N)

crisp root
#

i didnt do the prob

molten ferry
#

instead of heap

tawny relic
molten ferry
#

cuz u cant call the max function cuz u need the key

#

or atleast idk how u would call the max function on the values and get they key in pyto=hon

crisp root
#

Idk if that’s what u meant tho

molten ferry
#

yea

#

i didnt call the max thing

#

i looped through and everytime i would see a greater value,

#

i stored the key

#

my interviwer said return a list of strings

#

so if i saw a new value greater than mine

#

i would do
while len(list) > 0:
list.pop()

stark socket
#

from collections import defaultdict, Counter

logs = [
{'user': '1', 'page': 'A'},
{'user': '2', 'page': 'B'},
{'user': '1', 'page': 'B'},
{'user': '1', 'page': 'D'},
{'user': '2', 'page': 'A'},
{'user': '3', 'page': 'B'},
{'user': '3', 'page': 'D'},
{'user': '1', 'page': 'C'},
{'user': '3', 'page': 'C'},
{'user': '1', 'page': 'C'},
{'user': '2', 'page': 'C'},
{'user': '3', 'page': 'B'},
{'user': '1', 'page': 'A'},
{'user': '3', 'page': 'C'},
]

def get_history_by_user(logs):
history = defaultdict(list)
for log in logs:
history[log['user']].append(log['page'])
return history

def get_history_combinations(history):
combinations = Counter()

for pages in history.values():
    if len(pages) < 3:
        continue
    for i in range(len(pages) - 2):
        sequence = tuple(pages[i:i+3])  # Use tuple to make it hashable
        combinations[sequence] += 1
        
return combinations

def get_max_combination(combinations):
max_count = 0 # Stores the highest count found
max_sequence = None # Stores the sequence corresponding to the highest count

for sequence in combinations:  # Iterate over all sequences
    count = combinations[sequence]  # Get the count for this sequence
    
    if count > max_count:  # If it's the highest count so far, update
        max_count = count
        max_sequence = sequence

return max_sequence  # Return the most frequent sequence

history = get_history_by_user(logs)
combinations = get_history_combinations(history)
most_popular_sequence = get_max_combination(combinations)

print(most_popular_sequence)

molten ferry
#

or smth idr