LeetCode Çözümleri – 100. Same Tree [Google Mülakat Sorusu]

LeetCode içerisinde bulunan “Same Tree”‘ sorusunun açıklaması ve çözümü. Bu soruda verilen iki binary tree’nin hem yapısal olarak, hem de node değerleri bakımından eşit olup olmadığını bulmanızı istemekte. LeetCode’a göre bu soru Google mülakatlarında sorulmuş sorulardan biri.

🔥 LeetCode 100. Same Tree: https://leetcode.com/problems/same-tree/

🔥 Carnegie Mellon Üniversitesi binary tree linki: https://www.cs.cmu.edu/~adamchik/15-121/lectures/Trees/trees.html

➡️ Problem açıklaması:

Given two binary trees, write a function to check if they are the same or not.

Two binary trees are considered the same if they are structurally identical and the nodes have the same value.

Example 1:

Input: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3]

Output: true

Example 2:

Input: 1 1 / \ 2 2 [1,2], [1,null,2]

Output: false

Example 3:

Input: 1 1 / \ / \ 2 1 1 2 [1,2,1], [1,1,2]

Output: false

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.