Facebook Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
1
of 1 vote

What's a scoring sequence? I think I may know what kind of thing you're talking about. Is this problem akin to "If a basketball team scored 80 points in a game, how many scoring sequences of 2 or 3 points are possible?" In this case, the answer would be F(n) = F (n-2) + F(n-3), subject to base cases of F(2) = F(3) = 1 and F(1) = 0.

- eugene.yarovoi March 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

have to be in order :sequence not combine

- qq April 07, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

it works. the sequence is considered.

- nanny October 31, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

I start by thinking of it as a coin problem - given a total amount, how many different ways can you get that amount? So the 'score' is the amount, and the points are the coin values.

For example, if score was s=100, and points were either {3, 5, 7} the minimum number of shots scored would be 16 (7x13 + 3x3). You can work backwards from there to find all other possible combinations of shots that would result in a score of 100.

For each individual combination of shots, you then have to multiply by the different ways those shots could be ordered. For example, all thirteen 7 pointers followed by the three 3 pointers, etc.

This is calculated by [total shots]! / [score-count-1]![score-count-2]!... so, there are 16!/13!3! or 560 different ways you could make thirteen 7-pointers and three 3-pointers.

- Jeremy July 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you give some example???

- NaiveCoder March 06, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#define SIZE 3
int tab[SIZE]={4, 10, 15};
int score=80;

int f(s)
{
  printf(" %d", s);
  if(s<0) 
  {
    printf(" nope\n");
    return(0);
  }
  else
  if(!s)
  {
    printf(" found\n");
    return(1);
  }
  else
  {
    return(f(s-tab[0]) || f(s-tab[1]) || f(s-tab[2]));
  }
}

The lines ending with found is the results

- CheckThisResume.com March 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I tried this code and I don't think this is the right way. At least, not satisfy the case that score 18 with the combination of 3 and 5.

- xiaojian@buffalo.edu April 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

answer(x) = 2^x
EOF

- tom March 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

answer(x) = 2^x
EOF

- tom March 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

// example
// f(4)
//
// 1 1 1 1
// 2 1 1
// 1 2 1
// 1 1 2
// 2 2
// 3 1
// 1 3
// 4

public static void main(String[] args) {
    assert getSeqCount(4) == 8;
    assert getSeqCount2(4) == 8;
}

/**
 * DP (quadratic)
 */
private static int getSeqCount2(int n) {
    int[] dp = new int[n + 1];
    dp[0] = dp[1] = 1;
    for (int i = 2; i < dp.length; i++) {
        for (int j = 0; j < i; j++) {
            dp[i] += dp[j];
        }
    }
    return dp[n];
}

/**
 * naive recursive (exponential)
 */
private static int getSeqCount(int n) {
    if (n <= 1) {
        return 1;
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
        int newN = n - i;
        if (newN >= 0) {
            res += getSeqCount(newN);
        }
    }
    return res;
}

- Safi December 11, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

bool is_bst(struct Node * node) {
return (node->left == NULL && node->right == NULL) ||
(
(node->left == NULL || (node->left->value<=node->value && is_bst(node->left)
&&
(node->right == NULL || (node->right->value>=node->value && is_bst(node->right);
);
}

- Anonymous March 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

WTF

- Anonymous May 16, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More