You need to implement a DataStream class that processes a stream of integers and checks whether the last k integers in the stream are equal to a specified value.
You are given an integer array nums. The xor-beauty of the array is the XOR of the effective values of all possible triplets of indices (i, j, k) where 0 <= i, j, k < n. The effective value for each triplet is calculated as ((nums[i] | nums[j]) & nums[k]).
You are given a list of integers nums and an integer k. In each operation, you choose an index i, increase your score by nums[i], and replace nums[i] with ceil(nums[i] / 3). Apply exactly k operations and return the maximum score you can achieve.
You are given two strings, word1 and word2. In each move, you swap one character from word1 with one from word2. Determine if it is possible to make the number of distinct characters in both strings equal with exactly one swap.
You are given a positive integer n representing the size of an n x n matrix initially filled with zeros, and a 2D integer array queries. Each query consists of four integers [row1, col1, row2, col2]. For each query, add 1 to every element in the submatrix from (row1, col1) to (row2, col2) in the matrix. Return the matrix after applying all queries.
Given an integer array nums and an integer k, return the number of “good” subarrays. A subarray is good if it contains at least k pairs of indices (i, j) such that i < j and nums[i] == nums[j]. A subarray is a contiguous non-empty sequence of elements within the array.