#n keys, and assume strongly connected

1 messages · Page 1 of 1 (latest)

dreamy axle
#

so it's n^2 because for each key you could have n nodes in that node's values?

worthy fern
#

assuming every node is connected to every other node

#

in that case ur adj list is kinda useless

dreamy axle
#

yeah

worthy fern
#

bc in a matrix at least u can just check if the value is set

#

and that would be O(1)

#

assuming u initialized NxN grid

#

wait im confusing

#

time with space again sry

#

but yeah point still stands

dreamy axle
#

yeah that makes sense

#

but in any case when you have a hashmap that has n keys and the value for each key could be an array up to n nodes, the Space would be n^2 right?

worthy fern
#

yeah

dreamy axle
#

ty

worthy fern
#

n keys with n values each

dreamy axle
#

hey, anoter quick question about space if that's okay. if I slice a string str[:i] but immediatley convert it to an int(str[i;]) is this adding to space complexity? if nothing else was stored, would the slice still result in a O(n) overall SC where n is len of str