Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Spencer Lan
'NoneType' object has no attribute 'val'

Spencer Lan

Sep 29, 2025

I'm getting this error even with correct solution, seems like the tree might not be built out correctly for the tests

0

0

Comments
Comments
Spencer Lan
Spencer Lan23 days ago
from collections import deque #class TreeNode: # def __init__(self, val): # self.val = val # self.left, self.right = None, None class Solution: def findSuccessor(self, root, key): if not root: return None queue = deque([root]) ...
Spencer Lan
Spencer Lan23 days ago

I might be missing something but I used deque instead of queue here

On this page