#Ur syntax might be wrong
1 messages · Page 1 of 1 (latest)
Create an init func for solution
Initialize array therr
Initialize array in Solutions
init(self)
Function
Oh it didnt get my underscores
ohhh ok ok let me try that
Google python init if udk it
Im too lazy cause im in bed rn
To format my msg properly
thanks so much! thats all i needed
wowwww
ok ok wait so i cant just make global variables like that?
In ur kthSest
kthSmallest
Ur calling self.array
Im ur old code
Python interpreter doesnt know if class has a self.array
Does that make sense?
Theres a bunch of reasons
what if i had removed the self
Just keep practicing and reading python syntax
would it have worked?
Unsure
Probably not though
Youd need some
Nonlocal
Or global keyword
In kthSmallest
i see i see, so always keep a init if i want global variables
In classes
U use init
If there was no class Solution
Ur old solution would have worked if u made self.array just array
i seeee aight aight
thanks a lot!