Facebook | Phone screen | Sum to target

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2019-07-09Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: e3/e4
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

I am accessed by their recruiter from Singapore in LinkedIn.
And I passed the 1st round phone screen, the questions mainly focus on the experience I have and management I got, and the project I currently work. The other behavioral questions like what's the point you like/dislike your current job?

I was scheduled to have technical phone interview with someone in US.

Question:
Add (insert) the mathematical operators + or - (plus or minus) before any of the digits in the decimal numeric string "123456789" such that the resulting mathematical expression adds up to a particular target sum. Return all possible combinations. https://rosettacode.org/wiki/Sum_to_100

Example:
123 + 4 - 5 + 67 - 89   =   100  

I started with some easy case,like "1","12"...
to analyze how to trace back with subset
to generalize the case, finally I wrote a rough draft function.

It took most of time to complete the cases, and when he asked me the complexity of the function I wrote.
I gave wrong answer..but time is up, he didn't ask me to consider again.

I did my best, it's still rejected.

Comments