You are given an array of integers data, where each integer represents one byte of data. Your task is to check whether this sequence of bytes forms a valid UTF-8 encoded string based on the UTF-8 encoding rules for 1 to 4 bytes characters.
You are given a string that is encoded using the pattern k[encoded_string], where the substring inside the square brackets is repeated exactly k times. Your task is to decode the string by expanding it according to the given encoding rule.
Given a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greater than or equal to k. If no such substring exists, return 0.
You are given an integer array nums of length n. For each rotation k, we define a function F(k) which is calculated as: F(k) = 0 * arrk[0] + 1 * arrk[1] + … + (n-1) * arrk[n-1]. The goal is to return the maximum value of F(k) for all possible k in the range from 0 to n-1.
Given a positive integer n, you can perform one of the following operations: If n is even, divide n by 2. If n is odd, you can either add 1 to n or subtract 1 from n. Your task is to return the minimum number of operations required to reduce n to 1.
Given an integer array nums with potential duplicates, you need to randomly select an index i where nums[i] == target. If there are multiple indices with the same value, the selection should be made with equal probability for each valid index.