[Hacker Earth] Counting tripletsRead more
[Hacker Earth] Array GameRead more
[Codeforces] Educational Round 40 (Rated for Div. 2) G. Castle DefenseRead more
[Codeforces] Helvetic Coding Contest 2018 online mirror (teams allowed, unrated) A2. Death Stars (medium)Read more
[Codeforces] Helvetic Coding Contest 2018 online mirror (teams allowed, unrated) C2. Encryption (medium)Read more
[Codeforces] Educational Round 41 (Rated for Div. 2) D. Pair Of LinesRead more
[Codeforces] Tinkoff Internship Warmup Round 2018 and Codeforces Round 475 (Div. 1) B. Destruction of a TreeRead more
[LeetCode] Find Mode in Binary Search Tree

501. Find Mode in Binary Search Tree

Given the root of a binary search tree (BST) with duplicates, return all the mode(s)) (i.e., the most frequently occurred element) in it.

If the tree has more than one mode, return them in any order.

Assume a BST is defined as follows:

  • The left subtree of a node contains only nodes with keys less than or equal to the node’s key.
  • The right subtree of a node contains only nodes with keys greater than or equal to the node’s key.
  • Both the left and right subtrees must also be binary search trees.
Read more
[Hacker Earth] Palindromes EverywhereRead more
[Hacker Earth] Turn Off LightsRead more