[CodeChef] Car-pal TunnelRead more
[CodeChef] Sum Product SegmentsRead more
[CodeChef] War of XORsRead more
[Codeforces] Round #742 (Div. 2) C. Carrying ConundrumRead more
[Codeforces] Round #750 (Div. 2) D. Vupsen, Pupsen and 0Read more
[Codeforces] Round #748 (Div. 3) E. Gardener and TreeRead more
[Codeforces] Round #752 (Div. 1) B. Moderate Modular ModeRead more
[Codeforces] Round #753 (Div. 3) E. Robot on the Board 1Read more
[LeetCode] Height of Binary Tree After Subtree Removal Queries

2458. Height of Binary Tree After Subtree Removal Queries

You are given the root of a binary tree with n nodes. Each node is assigned a unique value from 1 to n. You are also given an array queries of size m.

You have to perform m independent queries on the tree where in the ith query you do the following:

  • Remove the subtree rooted at the node with the value queries[i] from the tree. It is guaranteed that queries[i] will not be equal to the value of the root.

Return an array answer of size m where answer[i] is the height of the tree after performing the ith query.

Note:

  • The queries are independent, so the tree returns to its initial state after each query.
  • The height of a tree is the number of edges in the longest simple path from the root to some node in the tree.
Read more
[LeetCode] Minimum Addition to Make Integer Beautiful

2457. Minimum Addition to Make Integer Beautiful

You are given two positive integers n and target.

An integer is considered beautiful if the sum of its digits is less than or equal to target.

Return the minimum non-negative integer x such that n + x is beautiful. The input will be generated such that it is always possible to make n beautiful.

Read more