You are given a 2D binary grid, where ‘1’ represents a security device and ‘0’ represents an empty cell. A laser beam can be formed between two devices if they are located on two different rows and no security device is in any row between them. The task is to find the total number of laser beams that can be formed.
You are given a string consisting of multiple words separated by spaces. For each word, you need to change the capitalization based on the length of the word. If the word has 1 or 2 letters, it should be entirely in lowercase. If the word has 3 or more letters, the first letter should be uppercase and the remaining letters should be lowercase. Return the modified string with the updated capitalization for each word.
You are given an array of strings, where each string consists of two lowercase English letters. The task is to create the longest possible palindrome by selecting some of these strings and concatenating them in any order. Each string can be used at most once. A palindrome is a string that reads the same forward and backward. Return the length of the longest palindrome that can be created, or 0 if it’s not possible to create any palindrome.
Given two arrays of strings, startWords and targetWords, determine how many strings in targetWords can be formed by appending a letter to any string in startWords and rearranging the letters.
Given a string s and an integer k, partition the string into groups of size k. If the last group has fewer than k characters, append a fill character to complete it. Return an array of the groups.
You are tasked with implementing a Bitset class that supports operations such as setting bits, clearing bits, flipping all bits, and querying the state of the bits (whether all bits are set to 1, at least one bit is set to 1, etc.).