Google | Phone Screen
Anonymous User
1745

Position - L3
Location - India

Recruiter contacted me probably because I work in a FAANG company.

  1. Given a circular linked list, remove odd indexed nodes.
    Ex - a->b->c->d->a convert to a->c->a
    a->b->c->a convert to a->c->a

    This is a straightforward warmup question which I was able to implement.

  2. Given an array of n numbers, find number of ways you can create k non empty subsets

Say (i, k) -> denotes number of ways you can make k non empty subsets with first i numbers

(i, k) = (i-1, k)*k + (i-1, k-1)
First term -> with i-1 elements if you create k buckets, we can put ith element into any of the k buckets
Second term -> form k-1 buckets with i-1 elements and put ith element in a new empty bucket forming k buckets in total.

Now this is a straightforward dp question but guess it was the nerves, I screwed up.

I've been actively preparing for interviews especially this one since some time and its a bummer I wasn't able do the second one but guess it is what it is and I just have to try again.

Comments (6)