Line 34: ValueError: Expecting property name: line 1 column 2 (char 1)

  • 0
    # Definition for a  binary tree node
    # class TreeNode:
    #     def __init__(self, x):
    #         self.val = x
    #         self.left = None
    #         self.right = None
    class Solution:
        # @param root, a tree node
        # @return a list of integers
        def rightSideView(self, root):
            if root == None:
                return []
            result, current_level = [], [root]
            while current_level:
                next_level = []
                for i in range(len(current_level)):
                    node = current_level.pop(0)
                    if i == 0:
                    if node.right:
                    if node.left:
                current_level = next_level
            return result

    I've tried different ways of implementing this, but all end up with the same Runtime Error

    ValueError: Expecting property name: line 1 column 2 (char 1)

    anybody knows what's wrong? Thanks!

  • 0

    This was due to a recent format change to the binary tree representation string. I have just fixed the issue, your could should get Accepted now. Sorry for the inconvenience.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.