All Posts

Leetcode 560: Subarray Sum Equals K

Given an array nums of integers and an integer k, find the total number of contiguous subarrays whose sum equals k.

Leetcode 713: Subarray Product Less Than K

Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k.

Leetcode 724: Find Pivot Index

Given an array of integers, find the pivot index where the sum of elements to the left equals the sum of elements to the right.

Leetcode 731: My Calendar II

You are implementing a calendar system where you can add events. Each event is represented by a start time and an end time, defined as a half-open interval [startTime, endTime). You need to ensure that no more than two events overlap at any given time, or else return false. Your task is to implement a class, MyCalendarTwo, that will book events while preventing triple bookings.

Leetcode 813: Largest Sum of Averages

You are given an integer array ’nums’ and an integer ‘k’. You can partition the array into at most ‘k’ non-empty adjacent subarrays. The score of a partition is defined as the sum of the averages of each subarray. Your goal is to return the maximum score that can be achieved by partitioning the array in any possible way, with each partition’s score calculated as the sum of averages of its subarrays.

Leetcode 848: Shifting Letters

You are given a string s of lowercase English letters and an array shifts, where shifts[i] represents the number of times to shift the first i + 1 characters of s. The shift operation for a letter means moving to the next letter in the alphabet, and if the letter is ‘z’, it wraps around to ‘a’. After applying all the shifts, return the final string.