[LeetCode] Rabbits in Forest

781. Rabbits in Forest

There is a forest with an unknown number of rabbits. We asked n rabbits “How many rabbits have the same color as you?” and collected the answers in an integer array answers where answers[i] is the answer of the ith rabbit.

Given the array answers, return the minimum number of rabbits that could be in the forest.

Read more
[LeetCode] Gray Code

89. Gray Code

An n-bit gray code sequence is a sequence of 2n integers where:

  • Every integer is in the inclusive range [0, 2n - 1],
  • The first integer is 0,
  • An integer appears no more than once in the sequence,
  • The binary representation of every pair of adjacent integers differs by exactly one bit, and
  • The binary representation of the first and last integers differs by exactly one bit.

Given an integer n, return any valid n-bit gray code sequence.

Read more
[Codeforces] Round #778 (Div. 1 + Div. 2, based on Technocup 2022 Final Round) C. Alice and the CakeRead more
[Codeforces] Round #790 (Div. 4) H1. Maximum Crossings (Easy Version)Read more
[Hacker Rank] Subset ComponentRead more
[Hacker Rank] Floyd : City of Blinding LightsRead more
[Hacker Rank] Jack goes to RaptureRead more
[Hacker Rank] Snakes and Ladders: The Quickest Way UpRead more
[LeetCode] Equal Tree Partition

663. Equal Tree Partition

Given the root of a binary tree, return true if you can partition the tree into two trees with equal sums of values after removing exactly one edge on the original tree.

Read more
[LeetCode] Shifting Letters

848. Shifting Letters

You are given a string s of lowercase English letters and an integer array shifts of the same length.

Call the shift() of a letter, the next letter in the alphabet, (wrapping around so that ‘z’ becomes ‘a’).

  • For example, shift(‘a’) = ‘b’, shift(‘t’) = ‘u’, and shift(‘z’) = ‘a’.

Now for each shifts[i] = x, we want to shift the first i + 1 letters of s, x times.

Return the final string after all such shifts to s are applied.

Read more