All Posts

Leetcode 881: Boats to Save People

You are given a list of people where each person has a certain weight, and a boat with a weight limit. Each boat can carry at most two people at the same time, as long as their combined weight does not exceed the boat’s weight limit. Your task is to determine the minimum number of boats required to rescue everyone.

Leetcode 885: Spiral Matrix III

You are given a grid of size rows x cols, where each cell represents a coordinate. You start at a given coordinate (rStart, cStart), facing east, and your goal is to walk in a clockwise spiral through the grid. As you walk, you must visit each cell exactly once. Once you reach the boundary of the grid, continue walking outside the grid, but you may return to the grid later. Return a list of the coordinates you visit in the order you encounter them.

Leetcode 889: Construct Binary Tree from Preorder and Postorder Traversal

You are given two integer arrays representing the preorder and postorder traversals of a binary tree. Your task is to reconstruct the binary tree from these two traversals and return the root node of the tree.

Leetcode 893: Groups of Special-Equivalent Strings

You are given an array of strings where each string is of the same length. In one move, you can swap any two characters at even indexed positions or any two characters at odd indexed positions in a string. Two strings are considered special-equivalent if they can be made identical after performing any number of such moves. Your task is to determine how many distinct groups of special-equivalent strings exist in the given array.

Leetcode 896: Monotonic Array

An array is said to be monotonic if it is either monotonically increasing or monotonically decreasing. A monotonically increasing array is one where each element is greater than or equal to the previous one, and a monotonically decreasing array is one where each element is less than or equal to the previous one. Given an integer array, return true if the array is monotonic, and false otherwise.

Leetcode 898: Bitwise ORs of Subarrays

Given an array of integers, return the number of distinct bitwise OR results from all the non-empty subarrays. A subarray is a contiguous sequence of elements from the array, and the bitwise OR of a subarray is the bitwise OR of each of the integers in that subarray.