All Posts

Leetcode 2680: Maximum OR

You are given a 0-indexed integer array nums of length n and an integer k. In each operation, you can pick an element from the array and multiply it by 2. Your goal is to determine the maximum possible value of the bitwise OR of all elements in the array after applying the operation at most k times.

Leetcode 2682: Find the Losers of the Circular Game

In this game, there are n friends sitting in a circle, numbered from 1 to n. The game starts with the 1st friend receiving a ball. The ball is passed to a friend k steps away in a clockwise direction, and then on each subsequent turn, the ball is passed to the friend i * k steps away, where i is the turn number (starting from 1). The game ends when any friend receives the ball for the second time. The friends who never receive the ball are considered the losers. The task is to return the list of losers in ascending order.

Leetcode 2683: Neighboring Bitwise XOR

You are given a binary array derived of length n. The derived array is obtained by computing the bitwise XOR of adjacent values in an original binary array. Specifically, for each index i, if i is the last index, derived[i] = original[i] ⊕ original[0], otherwise, derived[i] = original[i] ⊕ original[i + 1]. The task is to determine if there exists a valid binary array original that could have formed the given derived array.

Leetcode 2684: Maximum Number of Moves in a Grid

You are given a matrix grid of size m x n filled with positive integers. Starting from any cell in the first column, you can move to any of the cells on the next column (right) that are strictly greater than the value of the current cell. The possible directions you can move to are: the cell directly to the right, the cell diagonally to the top-right, or the cell diagonally to the bottom-right. Your task is to return the maximum number of moves that you can perform by starting at any cell in the first column.

Leetcode 2706: Buy Two Chocolates

You are given an integer array representing the prices of chocolates in a store and a total amount of money you have. Your task is to buy exactly two chocolates in a way that ensures you still have some leftover money, and you want to minimize the sum of the prices of the two chocolates. If you cannot buy two chocolates without going into debt, return the original amount of money you had.

Leetcode 2707: Extra Characters in a String

You are given a string and a list of words. Your task is to break the string into one or more non-overlapping substrings such that each substring is a word from the given list. However, some characters of the string may not be used in any substring. Your goal is to minimize the number of unused characters.