All Posts

Leetcode 1865: Finding Pairs With a Certain Sum

You are given two integer arrays nums1 and nums2. Your task is to implement a data structure that supports two types of operations: 1) Add a value to an element in nums2. 2) Count the number of pairs (i, j) such that nums1[i] + nums2[j] equals a given total value.

Leetcode 1993: Operations on Tree

You are given a tree with n nodes numbered from 0 to n - 1 represented by a parent array. You need to implement the LockingTree class with methods for locking, unlocking, and upgrading nodes in the tree based on certain conditions.

Leetcode 2013: Detect Squares

You are given a stream of 2D points on the XY-plane. Your task is to design an algorithm that adds new points into a data structure and counts how many sets of three points, along with a given query point, can form an axis-aligned square. An axis-aligned square is a square where the edges are parallel or perpendicular to the X-axis and Y-axis, with all sides of equal length.

Leetcode 2034: Stock Price Fluctuation

You are given a stream of stock price records, where each record contains a timestamp and the corresponding price of the stock. The records may not be in order, and some records may contain errors that need to be corrected. Your task is to design an algorithm that updates the stock price at a given timestamp, finds the current price at the latest timestamp, and also finds the maximum and minimum prices the stock has been based on the current records.

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 2069: Walking Robot Simulation II

A robot is placed on a grid and initially faces East. It is instructed to move forward by a specified number of steps. If the robot attempts to move out of bounds, it turns 90 degrees counterclockwise and tries again. The task is to implement a class for the robot that can handle these movements and return its current position and direction.