Tress&Graphs
Tress&Graphs
4. Symmetric Tree
Description: Check whether a binary tree is a mirror of itself (symmetric around its
center).
Test Cases: - Input: [1,2,2,3,4,4,3] → Output: true
- Input: [1,2,2,null,3,null,3] → Output: false
2. Clone Graph
Description: Clone an undirected graph. Each node contains a value and a list of
neighbors.
Test Cases: - Input: Node with value 1 connected to 2 and 4, 2 to 1 and 3, 3 to 2 and 4,
4 to 1 and 3 → Output: Cloned graph with same structure
5. Word Ladder
Description: Given two words and a dictionary, find the shortest transformation
sequence from beginWord to endWord.
Test Cases: - Input: beginWord = “hit”, endWord = “cog”, wordList =
[“hot”,“dot”,“dog”,“lot”,“log”,“cog”] → Output: 5
- Input: beginWord = “hit”, endWord = “cog”, wordList = [“hot”,“dot”,“dog”,“lot”,“log”] →
Output: 0