All Posts

Leetcode 915: Partition Array into Disjoint Intervals

Given an integer array nums, partition it into two contiguous subarrays, left and right, such that all elements in left are less than or equal to all elements in right. The size of left should be as small as possible, and both subarrays must be non-empty. Your task is to return the length of the left subarray after performing such a partition.

Leetcode 916: Word Subsets

Given two arrays of strings words1 and words2, find all the strings in words1 that are universal. A string from words1 is considered universal if it contains all the letters of every string in words2, including multiplicity. Each string in words2 is a subset of the string from words1.

Leetcode 918: Maximum Sum Circular Subarray

You are given a circular integer array nums of length n. A circular array means that the end of the array connects back to the beginning. Your task is to find the maximum possible sum of a non-empty subarray of nums, which can wrap around the array. Formally, you need to find the maximum sum of a subarray where the subarray can either be within the linear array or it can wrap around from the end to the beginning.

Leetcode 919: Complete Binary Tree Inserter

You are given a complete binary tree. A complete binary tree is one where every level, except possibly the last, is completely filled, and all nodes are as far left as possible. Your task is to design a data structure that supports inserting new nodes while maintaining the completeness of the binary tree. Implement the CBTInserter class that supports two operations: inserting a new node and returning the root of the tree.

Leetcode 921: Minimum Add to Make Parentheses Valid

You are given a string consisting of parentheses. In one move, you can insert a parenthesis (either ‘(’ or ‘)’) at any position in the string. Your task is to return the minimum number of moves required to make the string valid, meaning all parentheses are properly balanced.

Leetcode 926: Flip String to Monotone Increasing

You are given a binary string s consisting of only ‘0’s and ‘1’s. A binary string is called monotone increasing if all ‘0’s appear before ‘1’s. You can flip any character in the string, changing it from ‘0’ to ‘1’ or from ‘1’ to ‘0’. Your task is to return the minimum number of flips required to make the string monotone increasing.