Design a memory allocator class with functions to allocate and free blocks of memory. The allocator should efficiently handle consecutive memory requests and be able to free blocks based on their identifiers.
You are given a list of words, where each word consists of lowercase English letters. Two words are considered similar if they contain the exact same set of unique characters, regardless of the order. Your task is to count how many pairs of words (i, j) satisfy the condition where both words have the same set of unique characters. Return the count of such pairs (i, j) where 0 ≤ i < j ≤ len(words) - 1.
You are given two lists of words: one representing positive feedback and the other representing negative feedback. Each feedback word affects a student’s points: a positive word adds 3 points, while a negative word subtracts 1 point. For each feedback report, which is associated with a student, calculate the total score by counting the occurrences of positive and negative words. After evaluating all reports, return the top k students based on their total points. In case of a tie in points, the student with the lower ID should rank higher.
You are given a string s consisting of the characters ‘a’, ‘b’, and ‘c’, and a non-negative integer k. Each minute, you can choose to take either the leftmost or the rightmost character from s. Your task is to determine the minimum number of minutes required to collect at least k occurrences of each character (‘a’, ‘b’, and ‘c’). If it is not possible to collect k of each character, return -1.
Given an array of positive integers nums, find the number of distinct prime factors in the product of all the elements in the array. A prime factor of a number is a number that divides it evenly, and only divisible by 1 and itself. The goal is to calculate the distinct prime factors present in the prime factorization of the product of all elements in nums.
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.