All Posts

Leetcode 2043: Simple Bank System

You are required to build a system for a bank that automates various account transactions, including deposits, withdrawals, and transfers. The bank has multiple accounts, and each transaction must adhere to specific rules to be considered valid. Implement a class that handles these operations efficiently while ensuring transactional integrity.

Leetcode 2044: Count Number of Maximum Bitwise-OR Subsets

Given an integer array nums, find the maximum bitwise OR that can be achieved by any subset of nums and count how many different non-empty subsets yield this maximum value. A subset is defined as any combination of elements from the array, and subsets are considered different if their elements are selected from different indices.

Leetcode 2049: Count Nodes With the Highest Score

You are given a binary tree with n nodes, where each node is labeled from 0 to n-1. The tree is represented by a 0-indexed array parents, where parents[i] indicates the parent of node i. The root node has no parent, so parents[0] == -1.

Each node has a score, calculated as follows:

  1. If the node and the edges connected to it are removed, the tree splits into one or more non-empty subtrees.
  2. The score of a node is the product of the sizes of all resulting subtrees.

Return the number of nodes with the highest score in the tree.

Leetcode 2053: Kth Distinct String in an Array

Find the k-th unique string in an array based on its first occurrence. If fewer than k unique strings exist, return an empty string.

Leetcode 2054: Two Best Non-Overlapping Events

Find the maximum sum of values you can achieve by attending at most two non-overlapping events.

Leetcode 2055: Plates Between Candles

You are tasked with processing a string of plates (’*’) and candles (’|’) arranged on a table. For a set of queries, you must determine the number of plates that are enclosed by candles within specified substrings of the string.