PracHub
QuestionsPremiumLearningGuidesInterview PrepCoaches
|Home/Coding & Algorithms/Bloomberg

Solve two array and string problems

Last updated: Mar 29, 2026

Quick Overview

This two-part question evaluates combinatorial enumeration and subset-generation concepts for arrays alongside string parsing and parentheses-sequence validation for noisy input, measuring algorithm design, correctness, and complexity reasoning in array and string contexts.

  • medium
  • Bloomberg
  • Coding & Algorithms
  • Software Engineer

Solve two array and string problems

Company: Bloomberg

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You will solve two independent coding tasks. ### Problem 1: Generate All Subsets of a Set You are given an integer array `nums` containing `n` **distinct** elements. Return all possible subsets (the power set) of `nums`. - A subset can be of any size from `0` to `n`. - The order of subsets in the output does not matter. - The order of elements inside a subset also does not matter. **Example** Input: - `nums = [1, 2, 3]` One valid output (order may differ): - `[ [], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3] ]` **Constraints** - `1 <= n <= 20` - `-10^9 <= nums[i] <= 10^9` - All `nums[i]` are distinct. You may return the result in any order. --- ### Problem 2: Validate Parentheses in a Noisy String You are given a string `s` that may contain: - the characters `'('` and `')'`, and - any other characters (letters, digits, punctuation, etc.). A string is considered **parentheses-valid** if, after **ignoring all non-parenthesis characters**, the remaining sequence of `'('` and `')'` is a valid parentheses sequence: - Every opening parenthesis `'('` has a corresponding closing parenthesis `')'`. - Parentheses are properly nested. Implement a function that returns `true` if `s` is parentheses-valid, and `false` otherwise. **Examples** 1. Input: `s = "a(b)c"` - Ignoring non-parenthesis characters, we get `"()"` which is valid. - Output: `true`. 2. Input: `s = "(a(b)c"` - Ignoring non-parenthesis characters, we get `"(()"` which is not valid. - Output: `false`. 3. Input: `s = "ab)c(d)e"` - Ignoring non-parenthesis characters, we get `")()"` which is not valid. - Output: `false`. **Constraints** - `1 <= len(s) <= 10^5` - `s` may contain any printable ASCII characters.

Quick Answer: This two-part question evaluates combinatorial enumeration and subset-generation concepts for arrays alongside string parsing and parentheses-sequence validation for noisy input, measuring algorithm design, correctness, and complexity reasoning in array and string contexts.

Related Interview Questions

  • Solve meeting and tree problems - Bloomberg (easy)
  • Check connectivity between two subway stations - Bloomberg (easy)
  • Minimize travel cost with two cities - Bloomberg (easy)
  • Find tree root and bucket numbers - Bloomberg (hard)
  • Design a data structure for dynamic top‑K frequency - Bloomberg (hard)
Bloomberg logo
Bloomberg
Oct 16, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
7
0

You will solve two independent coding tasks.

Problem 1: Generate All Subsets of a Set

You are given an integer array nums containing n distinct elements.

Return all possible subsets (the power set) of nums.

  • A subset can be of any size from 0 to n .
  • The order of subsets in the output does not matter.
  • The order of elements inside a subset also does not matter.

Example

Input:

  • nums = [1, 2, 3]

One valid output (order may differ):

  • [ [], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3] ]

Constraints

  • 1 <= n <= 20
  • -10^9 <= nums[i] <= 10^9
  • All nums[i] are distinct.

You may return the result in any order.

Problem 2: Validate Parentheses in a Noisy String

You are given a string s that may contain:

  • the characters '(' and ')' , and
  • any other characters (letters, digits, punctuation, etc.).

A string is considered parentheses-valid if, after ignoring all non-parenthesis characters, the remaining sequence of '(' and ')' is a valid parentheses sequence:

  • Every opening parenthesis '(' has a corresponding closing parenthesis ')' .
  • Parentheses are properly nested.

Implement a function that returns true if s is parentheses-valid, and false otherwise.

Examples

  1. Input: s = "a(b)c"
    • Ignoring non-parenthesis characters, we get "()" which is valid.
    • Output: true .
  2. Input: s = "(a(b)c"
    • Ignoring non-parenthesis characters, we get "(()" which is not valid.
    • Output: false .
  3. Input: s = "ab)c(d)e"
    • Ignoring non-parenthesis characters, we get ")()" which is not valid.
    • Output: false .

Constraints

  • 1 <= len(s) <= 10^5
  • s may contain any printable ASCII characters.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Bloomberg•More Software Engineer•Bloomberg Software Engineer•Bloomberg Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.