Can You Count the Bit Strings?
Updated
Problem statement
A bit string is a string of bits that have values of either 1 or 0, A super bit string is a bit string made by flipping zero or more of the 0s in the bit string to 1.
Given k decimal integers, convert each to a bit string that has a given length n. Generate all possible super bitstrings of each of the k bit strings. Finally, perform a union of the super bit strings of all the bit strings and determine its size. This is the number to return.
Function
superBitstrings(n: int, bitStrings: int[]) → int
Complete the function superBitstrings in the editor.
superBitstrings has the following parameters:
- 1.
n: the required bit string length - 2.
int[] bitStrings: an array of decimal integers
Returns
int: the number of unique bitstrings that can be formed from all k values provided.
Examples
Example 1
n = 5bitStrings = [10, 26]return = 8As 5-bit strings, 10 is 01010 and 26 is 11010. 01010 has three 0s, so it has 2 × 2 × 2 = 8 super bit strings. 11010 has two 0s, so it has 4, and all of them are also super bit strings of 01010, because 11010 is one of them. The union has 8 strings.
Constraints
1 <= n <= 201 <= bitStrings.length <= 10000 <= bitStrings[i] < 2^n
More Snowflake interview questions
- Minimum StackPHONE SCREEN · Seen Nov 2026
- Design In-Memory File SystemPHONE SCREEN · Seen Nov 2026
- Merge Two Binary TreesPHONE SCREEN · Seen Nov 2026
- Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
- Minimum Edits to a Perfect Binary TreePHONE SCREEN · Seen Nov 2026
- Parallel Courses IIIONSITE INTERVIEW · Seen Nov 2026
- Safest Shortest Path Through a GridOA · Seen Nov 2026
- Configurable Per-Client Token BucketsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Find Valid SET Card TriplesOA · PHONE SCREEN · Seen Nov 2026
- LFU CacheOA · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
- Count One-Swap Number PairsCapital One · OACapital One interview questions
- Count Overlapping Square PairsRamp · OARamp interview questions
- Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
- Count Routes Through Four Shop TypesOpenAI · OAOpenAI interview questions
- Two Tribes from Taller-Person CountsIntuit · OAIntuit interview questions
- Get Triplet CountIBM · OAIBM interview questions
- How Many Sentences?Chubb · OAChubb interview questions
- Count Reverse-Digit PairsVisa · OAVisa interview questions
- ABO Parent Genotype CombinationsUpstart · OAUpstart interview questions