Showing posts with label Facebook. Show all posts
Showing posts with label Facebook. Show all posts

Monday, June 4, 2012

Choose to be happy


Happiness is a choice. Why choose to murmur and be unhappy? Forget not to be be happy now.

Anybody can be a critic.

"In many ways, the work of a critic is easy. We risk very little yet enjoy a position over those who offer up their work and their selves to our judgment. We thrive on negative criticism, which is fun to write and to read. But the bitter truth we critics must face, is that in the grand scheme of things, the average piece of junk is more meaningful than our criticism designating it so. But there are times when a critic truly risks something, and that is in the discovery and defense of the new. The world is often unkind to new talent, new creations, the new needs friends... Not everyone can become a great artist, but a great artist can come from anywhere." - Brad Bird (via Anton Ego)

We have the freedom to choose. Do you want to choose to be the bitter critic or the inspiring artist?

Wednesday, January 26, 2011

Technical phone interview

Eventually I had the technical phone interview with Facebook. It went pretty well, I think, but did not result in further interviews. The interviewer was a relatively new engineer there that got a PhD doing distributed systems work.

The interviewer started out by asking me to say some more about my background. I mentioned briefly what I am currently doing and then went into more detail about my graduate work. The interviewer asked follow up questions that required me to go into more detail than I normally need to when answering this type of question. At one point the interviewer asked me to explain the unique contribution of my dissertation and I floundered a bit. Oh well.

I got asked "Why are you interested in Facebook?" I was honest here and said that basically "you guys came to me" and "Facebook is cool." I think this, more than anything else, is what deterred a future interview. If you are interviewing with a company, have some good reasons why you want to work there!

The interviewer shared a little about their background.

We also discussed hip-hop. Alright, so it is really HPPHP, High Performance PHP. It is a tool they use at Facebook to enable web designers to code in PHP and still get the performance of C++. The interviewer did some rough math on a hypothetical situation. Suppose we have 100,000 servers. Each of those servers costs $5000 for the hardware and then another $5000 for maintenance over three years. That's $1,000,000,000. HPPHP results in a 50% savings. Instead of 100,000 servers, we can get away with 50,000 servers. That's $500,000,000 in savings. Now consider if it is just 1% savings. That's still $10,000,000! One of the interviewer's points was that in academics, 1% is nothing. In the real world, it matters.

Of course, there was also a technical question. The interviewer had me go to a website which opened up a shared notepad-type interface. We could both type on this interface, although there was some lag. Once I got a strange pop-up come up because I tried to use an Emacs shortcut (fingers were on autopilot).

The interviewer listed some numbers in a sequence. My job was to figure out the next element in the sequence and then write some code that would print out the for n elements of the sequence. The sequence started at 1 and then each next number was the previous number read out loud. So 1, then 11 (one 1), then 21 (two 1s), and so on. Not too bad.

At first I tried to reason out the mathematical relationship between the numbers, but the interviewer quickly intercepted me and indicated there was not one to be found. The interviewer suggest I just code it up like I did it in my mind. So I did.
             1
            11
            21
          1211
        111221
        312211
      13112221
    1113213211
31131211131221

// Prints first n numbers in the sequence
void seq(string n)
{
    cout << 1;
    string last_number = "1";

    for( int num = 1 ; num < n ; num ++ )
    {
    
    
  // Last char
  char last_char = 'x'; 
  unsigned count = 0;
  string new_number = "";
  for( int x = 0; x < strlen(last_number) ; x++)
  {
    //character
    char c = last_number[x]; 
    if( c == last_char )
    {
        count++;
    }
    
    if(( c != last_char) ) 
    {
        if( count > 0)
        {
            new_number+=(itoa(count));
            new_number+=last_char; 
        }
        last_char = c;
        count = 1;
    } 
  }
     new_number+=(itoa(count));
     new_number+=last_char; 
  
    cout << new_number;
    last_number = new_number;
    
    //int y = atoi( c );
  }
}
The formatting is awful but the interviewer seemed satisfied with my response. Here is a version that I spent a few minutes getting to actually compile:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <cassert>

using namespace std;

// Prints first n numbers in the sequence
void seq(int n)
{
  if(n < 1) return;
  cout << 1 << endl;
  string last_number = "1";
  
  for( int num = 1 ; num < n ; num ++ )
  {
    // Last char
    char last_char = 'x'; 
    unsigned count = 0;
    string new_number = "";
    for( int x = 0; x < last_number.length() ; x++)
    {
      //character
      char c = last_number[x]; 
      if( c == last_char )
      {
        count++;
      }
      if(( c != last_char) ) 
      {
        if( count > 0)
        {
          ostringstream tmp;
          tmp << count;
          new_number+= tmp.str();
          new_number+=last_char; 
        }
        last_char = c;
        count = 1;
      } 
  }
    ostringstream tmp;
    tmp << count;
    new_number+= tmp.str();
    new_number+=last_char; 
    
    cout << new_number << endl;
    last_number = new_number;
  }
}

main(int argc, char** argv)
{
  assert(argc==2);
  seq(atoi(argv[1]));
} 
That compiles with g++ in cygwin and it appears to work correctly. I noticed a few mistakes in making the version that actually compiles and did things a bit differently in some places. Might be one of the reasons they didn't want another interview.

As I have written this up I recall the problem was posed as a basis case and an inductive case. That seems to indicate that a recursive function could also solve it. That would have been clever. Might have been what the interviewer hoping to see.

After writing the code the interviewer had to leave for another meeting. I got to ask one question, so I asked what Facebook was doing to maintain its culture as it became larger. He gave a semi-generic answer, which is about all I should have expected. Then that was all.

A few days later I emailed the recruiter to follow up, and the recruiter let me know they would not be pursuing further interviews with me at this time. It was actually a relief to not have to decide between a sweet job and our #1 location.

Monday, January 24, 2011

Facebook technical phone interview prep

After my initial Facebook interview the recruiter told me they wanted to have a technical phone interview with me. The recruiter then passed me on to somebody else who arranged the interview. Meanwhile, the recruiter sent me some tips on how to prepare.
Please research any recent news about Facebook for talking points and more information about the company. You may be asked questions as to what your favorite features of the site are, and how you might improve those features. It will be helpful to take some time to think about this beforehand.

Be prepared for technical questions involving coding or algorithms in your best language, design patterns, and more specific questions to your background. It may also help to review core CS concepts (data structures, binary trees, link lists, object oriented analysis/design) as well as subjects pertaining to the scale of our environment. Please be near a computer with internet access as you will be coding over a web application.

It will help to look at the puzzles on our careers page for some ideas on the types of problems they will potentially ask. For coding questions, you will be asked to produce clean, efficient code in a reasonable amount of time. You have 45 minutes on the call. If the interviewer gives you hints to improve your code, take them and run with them. It is good to adjust and work through the problems with the interviewer to show your thought process and problem solving ability.
Simple and straightforward enough. The recruiter also sent me a bunch of links to review. I had heard most of the news through TWiT and TWiG, but the list still provided a nice review.
In preparation I also set up Chrome to have bookmarks ready while I interviewed. That ended up not mattering much, but I will tell that story later.

Friday, January 21, 2011

Facebook phone interview

I recently had a preliminary phone interview with Facebook. The recruiter contacted me out of the blue saying they were looking for "rockstars." I almost marked it as spam, but then actually read it. Facebook is the kind of company that I can't at least consider should they choose to pursue me. Plus it is good to try and sharpen the saw every once in a while.

Here are the questions I was asked and some of the answers I gave:
  1. This position is in Palo Alto. Are you willing to relocate?
    Probably. I was being honest here. I think I would be more willing to consider moving than my wife, but working for Facebook is a singularly unique opportunity.
  2. Can you tell me a little bit about the work you are doing right now?
    Blah blah blah. I probably rambled a bit too much here. Oh well. I was out of practice and forgot the preparation that good interviewing requires.
  3. Do you use Facebook?
    Yes. I then told the interviewer that I landed my current job through networking on Facebook. The interviewer asked me to explain that, so I did (probably rambling too much again).
  4. How familiar are you with the technologies we use here at Facebook? Do you follow
    Not very. I know the features Facebook puts out, but not the underlying technologies.
  5. How comfortable are you with technical phone interviews?
    It's hit or miss. I'm out of practice. My actual answer was much more verbose. The straight answer is "I normally stink and do horribly at any technical interview," but that doesn't seem like a good thing to say. Plus, I do occasionally do well.
  6. How many guesses would it take you to find a number between 1 and 1000 if I tell you "high" or "low" after each guess?
    10. I figured they were getting at a binary search, which is O(log n).
  7. What is the run time complexity of inserting into a heap?
    I have no idea. I'll guess n*log(n). I could have tried to figure this out, but I was having a brain fart and decided it was pointless to try and brazen it out. The actual answer is O(log n). Okay, okay. Really it depends on the implementation.
  8. How many direct children can a node have in a binary tree?
    0, 1, or 2.
The interviewer then told me she would pass on my answers and my resume to a hiring manager and that I would hear back in the next few days. The next morning she emailed me to set up a 45 minute technical interview.

Trying to get a job at Facebook? You do have an up-to-date profile on Facebook, right? After that, I would start by poking around at their careers site. I noticed they have a intriguing puzzles section that it probably wouldn't hurt to solve. Facebook has several recruiters on LinkedIn, so just do a search for "facebook recruiter" to get some contact information for a real person.