leetle

Daily challenge for 2026-05-03

488. Count Sibling Pairs with Same Value

Given a binary tree represented as an array where null indicates an empty node, count the number of sibling pairs (two nodes that share the same parent) that have the exact same value. The root is at index 0. For any node at index i, its left child is at 2*i + 1 and its right child is at 2*i + 2.

Example:
Input: tree = [1, 2, 2, 3, 4, 4, 4]
Output: 2
Explanation: The siblings at indices 1 and 2 both have value 2. The siblings at indices 5 and 6 both have value 4.

Run this challenge interactively in Python or JavaScript when the app loads.