[LeetCode] The Latest Time to Catch a Bus

2332. The Latest Time to Catch a Bus

You are given a 0-indexed integer array buses of length n, where buses[i] represents the departure time of the ith bus. You are also given a 0-indexed integer array passengers of length m, where passengers[j] represents the arrival time of the jth passenger. All bus departure times are unique. All passenger arrival times are unique.

You are given an integer capacity, which represents the maximum number of passengers that can get on each bus.

The passengers will get on the next available bus. You can get on a bus that will depart at x minutes if you arrive at y minutes where y <= x, and the bus is not full. Passengers with the earliest arrival times get on the bus first.

Return the latest time you may arrive at the bus station to catch a bus. You cannot arrive at the same time as another passenger.

Note: The arrays buses and passengers are not necessarily sorted.

Read more
[LeetCode] Evaluate Boolean Binary Tree

2331. Evaluate Boolean Binary Tree

You are given the root of a full binary tree with the following properties:

  • Leaf nodes have either the value 0 or 1, where 0 represents False and 1 represents True.
  • Non-leaf nodes have either the value 2 or 3, where 2 represents the boolean OR and 3 represents the boolean AND.

The evaluation of a node is as follows:

  • If the node is a leaf node, the evaluation is the value of the node, i.e. True or False.
  • Otherwise, evaluate the node’s two children and apply the boolean operation of its value with the children’s evaluations.

Return the boolean result of evaluating the root node.

A full binary tree is a binary tree where each node has either 0 or 2 children.

A leaf node is a node that has zero children.

Read more
[AtCoder] F - Range Xor QueryRead more
[AtCoder] D - StampRead more
[AtCoder] D - Sum of differenceRead more
[AtCoder] E - Through PathRead more
[AtCoder] D - Choose MeRead more
[Codeforces] Round #454 (Div. 2, based on Technocup 2018 Elimination Round 4) B. Tic-Tac-ToeRead more
[Codeforces] Educational Round 35 (Rated for Div. 2) C. Three GarlandsRead more
[Codeforces] Educational Round 37 (Rated for Div. 2) C. Swap Adjacent ElementsRead more