Kth Largest Sum in a Binary Tree - Leetcode 2583 - Java

preview_player
Показать описание
Problem Description

You are given the root of a binary tree and a positive integer k.

The level sum in the tree is the sum of the values of the nodes that are on the same level.

Return the kth largest level sum in the tree (not necessarily distinct). If there are fewer than k levels in the tree, return -1.

Note that two nodes are on the same level if they have the same distance from the root.

Рекомендации по теме
join shbcf.ru