We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Just wanted to check how BFS solution would look like, but it is much more convoluted :sad_pepe:
import Queue from "./Queue"; export default function compare( a: BinaryNode<number> | undefined, b: BinaryNode<number> | undefined, ): boolean { const queue = new Queue< [BinaryNode<number> | undefined, BinaryNode<number> | undefined] >(); queue.enqueue([a, b]); while (queue.length) { const curr = queue.deque(); if (!curr) { continue; } if (curr[0] === undefined && curr[1] === undefined) { continue; } if (curr[0] === undefined || curr[1] === undefined) { return false; } if (curr[0].value !== curr[1].value) { return false; } queue.enqueue([curr[0].left, curr[1].left]); queue.enqueue([curr[0].right, curr[1].right]); } return true; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Just wanted to check how BFS solution would look like, but it is much more convoluted :sad_pepe:
The text was updated successfully, but these errors were encountered: