Two Sigma Interview Share|Two Sigma OA |75 minutes for two questions 2025 latest question review

610 Views
No Comment

10.12 Just done. Two Sigma Interview, this time OA is still on HackerRank platform, total time 75 minutes, two questions.
The overall feeling is that the quality of the questions is quite high, but the pace is relatively tight. The first question is a bit stronger in logical judgment, and the second question, although it looks very long, is actually just a calculation + string processing, which is a typical "paper tiger" question.

Two Sigma Interview Basic Information

Date: 2025.10.12

Duration: 75 minutes

Number of questions: 2

Difficulty: medium-low

Platform: HackerRank

Assist Mode: Programhelp No Trace Online + Voice Rhythm Reminder

Question 1

Balanced Split String with Wildcards

Determine the number of ways a string containing the characters '(', ')', '[', ']', and '?' can be divided into two non-empty substrings such that each substring can be rearranged to form a balanced string.

The '?' characters can be replaced with any bracket character ('(', ')', '[', or ']') as needed to achieve balance.
The two substrings together must cover the entire original string and cannot overlap.

A balanced string is one where all brackets are properly matched and nested.
For example.

"([])", "()[]", and "[[]]" are balanced.

"([)]", "(()", and "][" are not.

A substring is a contiguous block of the original string.

Example

Let
s=′[? (]? [? ′s = '[? (]? [?' s=′[? (]? [? [?

We can split it in the following two valid ways:

  1. s1 = '[? (]'s_1 = \text{'[? (]'}s1='[? (]', s2='? [?' s_2 = \text{'? [?'} s2='? [?'
    • Replace one '?' in s1s_1s1 with ) to make it rearrangeable to a balanced "()[]".
    • Replace the '?'s in s2s_2s2 with [] so it can be rearranged into "[][]".
  2. s1='[? (]??' s_1 = \text{'[? (]??'} s1='[? (]??' , s2='[?' s_2 = \text{'[?'} s2='[?'
    • Replace '?'s in s1s_1s1 to make it "()[][]".
    • Replace '?' in s2s_2s2 with ] to make "[]".

Thus, the total number of valid splits is 2.

Constraints

  • 4≤length of s≤1054 \leq \text{length of } s \leq 10^54≤length of s≤105
  • sss contains only '(', ')', '[', ']', and '?'

Question 2

Closest Pure Color

A color is represented as a 24-bit integer, with 8 bits each for red (R), green (G), and blue (B) components.
Each component ranges from 0 (low intensity) to 255 (high intensity).

The distance between two colors with RGB values (r1,g1,b1)(r_1, g_1, b_1)(r1,g1,b1) and (r2,g2,b2)(r_2, g_2, b_2)(r2 ,g2,b2) is given by: d=(r1-r2)2+(g1-g2)2+(b1-b2)2d = \sqrt{(r _1 - r_2)^2 + (g_1 - g_2)^2 + (b_1 - b_2)^2}d=(r1-r2)2+(g1 -g2)2 + (b1-b2)2

We compare a given pixel's color to these five pure colors.

Pure Color R G B
Black 0 0 0
White 255 255 255
Red 255 0 0
Green 0 255 0
Blue 0 0 255

Given a 24-bit binary string representing a pixel's RGB value, determine which pure color it is closest to.
If the pixel is equally close to multiple colors, output "Ambiguous".

Example

Input

n = 1
pixels = ["00000000111111110011111100"]

Step 1: Parse the binary string

Split into 3 components (8 bits each).

  • R = "00000000" → 0
  • G = "11111111" → 255
  • B = "00111100" → 60

Thus, the pixel's RGB = (0, 255, 60).

Step 2: Compute distance to each pure color

Step 3: Find the closest

The smallest distance is to Green (d = 60),
so the result is "Green".

Function Description

Complete the function closestColor with the following parameter(s).

def closestColor(pixels: List[str]) -> List[str].

Parameters

  • pixels[n]: an array of 24-bit binary strings representing pixels

Returns

  • List[str]: for each pixel, return the name of the closest pure color, or

Overall impression

This OA experience was very smooth with no fancy pitfalls.

  • The first question is about logic and the second question is about realization.
  • All are mid-range questions that can be broken down by analysis.

Programhelp The pacing reminder from Programhelp helps a lot in time management:

"45 minutes to hit the bottom on the first question, don't panic on the second question, and be sure to leave 25 minutes for the test."

It is this kind of rhythmic planning that allows many students to consistently pass all hidden cases in the last few minutes.

final conclusion

Two Sigma's OA is not difficult, but it is very much about clarity of thought and stability of implementation.
Especially in the first question of this "balanced" questions, many people tend to write complex stack logic, but instead of wasting time.
If you can familiarize yourself with the rhythm of the questions through mock or assist training in advance, you will naturally be more stable when you are on the field.

Programhelp Interview Assist Teamhelp you to get offer

We interviewed for Two Sigma, Jane Street, Citadel, IMC, Amazon, and many others:

No Trace Online OA Assist (HackerRank / CodeSignal / Codility)

Real-time voice prompts, ideas card points immediately remind

Mock Interviews + Thinking Frameworks

Helping you to take a high paying offer in the shortest possible time.

author avatar
jor jor
END
 0