Meta OA Interview Question: Product of Array Except Self and Word Break All Combinations

17 Views
No Comments

Q1. Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].

Input: [4, 3, 2, 1]

Output: [6, 8, 12, 24]

Please solve it without using the division operator and in O(n).

Q2. Given a short string S and a dictionary D, find out all possible ways to split S using words in D.

Test examples:

S = 'abcd', D = ['a', 'b', 'ab', 'cd'] -> ['a-b-cd', 'ab-cd']
S = 'aaa', D = ['a'] -> ['a a a']
S = 'abcd', D = ['ab'] -> []
S = 'abcd', D = ['abcd'] -> ['abcd']

This Meta interview set includes two classic problems: array prefix/suffix products and string segmentation with all valid reconstructions. The first problem is typically solved with two linear passes to build left and right products, avoiding division and achieving O(n) time. The second problem is a Word Break variant that requires enumerating every valid split of the string using dictionary words, usually solved with DFS/backtracking plus memoization or DP-assisted pruning.

END
 0