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 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 2685: Count the Number of Complete Components

You are given a graph with n vertices, numbered from 0 to n-1. The graph contains undirected edges described in a 2D array edges, where each element edges[i] = [ai, bi] indicates that there is an undirected edge between vertices ai and bi. A connected component is a subgraph in which there is a path between any two vertices, and no vertex is connected to vertices outside of the subgraph. A connected component is said to be complete if there is an edge between every pair of vertices in that component. Your task is to return the number of complete connected components in the graph.

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.

Leetcode 2708: Maximum Strength of a Group

You are given an integer array representing the scores of students in an exam. Your task is to form a non-empty group of students such that the group’s strength, defined as the product of their scores, is maximized. The goal is to return the maximum possible strength that can be achieved by choosing an optimal group of students.