My wrong solution got accept


  • 0
    L
    public class Solution {
    public boolean isSymmetric(TreeNode root) {
        long hash1 = Dfs(root, true);
        long hash2 = Dfs(root, false);
        return hash1 == hash2;
    }
    
    long Dfs(TreeNode node, boolean flag)
    {
        if(null == node)  return 10007;        
        long result = flag ? Dfs(node.left, flag) * (node.val + 10007) + Dfs(node.right, flag) : Dfs(node.right, flag) * (node.val + 10007) + Dfs(node.left, flag);        
        return result;
    }}

  • 0

    Could you please provide a testcase which your code return the wrong result?


Log in to reply
 

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