All Posts

Leetcode 870: Advantage Shuffle

Given two integer arrays nums1 and nums2 of the same length, the goal is to permute nums1 in a way that maximizes the number of indices i where nums1[i] > nums2[i]. Return any permutation of nums1 that achieves this.

Leetcode 876: Middle of the Linked List

You are given the head of a singly linked list. Your task is to find and return the middle node of the list. If there are two middle nodes, return the second one.

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 925: Long Pressed Name

Your friend is typing their name on a keyboard. Sometimes, while typing, a key might be long pressed, causing the character to be typed multiple times. Given the name and the typed string, determine if it is possible that the typed string could have been the result of long pressing some characters while typing the name.

Leetcode 948: Bag of Tokens

You are given an array of tokens and an initial amount of power. The goal is to maximize the score by playing the tokens strategically. In each turn, you can either play a token face-up or face-down. Playing a token face-up costs you power but increases your score, while playing a token face-down gains you power but decreases your score. Your task is to determine the maximum score you can achieve after playing the tokens.

Leetcode 969: Pancake Sorting

You are tasked with sorting an array of integers by performing a series of pancake flips. A pancake flip involves reversing the order of elements from the start of the array up to a specified index. The goal is to determine the sequence of flips needed to sort the array in ascending order.