All Posts

Leetcode 877: Stone Game

Alice and Bob are playing a game with an array of piles of stones. Each pile contains a positive number of stones, and the game proceeds as follows: Alice and Bob take turns, with Alice starting first. On each turn, a player can choose the entire pile of stones either from the beginning or the end of the array. The player who ends up with the most stones wins. Given the piles array, return true if Alice wins the game, or false if Bob wins, assuming both players play optimally.

Leetcode 894: All Possible Full Binary Trees

Given an integer n, return all possible full binary trees with exactly n nodes. Each node of the tree must have the value 0. A full binary tree is defined as a binary tree where each node has either 0 or 2 children.

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.

Leetcode 907: Sum of Subarray Minimums

Given an array of integers arr, find the sum of the minimum values of all contiguous subarrays of arr. Since the result can be very large, return it modulo 10^9 + 7.

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 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.