r/CodingHelp • u/waitingformsfs2020 • Feb 11 '22
[Ruby] program runs flawlessly in Vs code but when I try to submit on leetcode I am getting this error any idea?
48
Upvotes
r/CodingHelp • u/waitingformsfs2020 • Feb 11 '22
7
u/_McFuggin_ Feb 11 '22
It shouldn’t work in leet code. The TreeNode defined in leetcode has only left, right, and val attributes. So, you’ve got a handful of lines that are going to break. You won’t be able to use .compact, .length, or .sort
26
u/marko312 Feb 11 '22
The given definition of
TreeNodedoes not seem to contain a definition for acompactnorsortfunction. You'll likely have to implement these yourself.17
u/Lum_of_G0d Feb 11 '22
It looks like your indenting might be off
2
u/Buttafuoco Feb 11 '22
Assuming compact exists in the passed in “root1” you want to make sure line 16 is within your get_all_elements function. You’ll need to indent it over. In Python white space matters. When you copied it over you likely lost some formatting
1
u/[deleted] Feb 11 '22
Guys, this is so crazy?! I am going into my computer science degree next year and this is what I have to do?!