Sunday, August 31, 2014

Way of Interview

  1. "What is the hardest bug you've had to find and fix?"
  2. Give ten pages of code and figure out the design
  3. "What happens when you type http://www.google.com in a web browser address bar and press enter? You have 45 minutes, go as deep as you want with your explanation.
  4. code something from scratch in 3 hours, then explain my design and solution
  5. the best thing that they had created as a programmer
  6. I will usually ask for code samples before the interview, or look at what they have at github
  7. "what's in your feed reader" who do you follow?" and "how do you keep up to date?"
  8. Make two armies fight each other and output the result. Introduce an element of randomness".
  9. "What is your go-to language or the language that you are most proficient in?" and then "What would you change about <that language>?"
  10. Write a function that takes a function and two ints and applies it to the two ints. 
------------------------------------------------------------------------------------------------------------
  • "What is the hardest bug you've had to find and fix?"
  1. When skydrive brand changed to onedirve and deployed to df, page does not get displayed
  2. Multiple entries for single users in onedrive logs which cause data reporting invalid.
  • Give ten pages of code and figure out the design
  • "What happens when you type http://www.google.com in a web browser address bar and press enter? You have 45 minutes, go as deep as you want with your explanation.
  1. You enter "facebook.com" into the address bar.
  1. Browser resolves this to the numeric IP address (this can be cached by the OS or require a trip out to a DNS server).
  2. Browser issues a "HTTP/GET" request. It passes along an HttpRequest which includes metadata about the browser, user preferences (like preferred language) and any stored cookies for that domain.
  3. Facebook servers receive the request and their code begins to craft a response.
    1. Facebook will use the passed information including cookies to determine who the user is and what information to send back
  4. A HTTP Response is returned from Facebook including a status line (200 OK, etc). Headers which include content-type, etc and the HTML body.
  5. The browser receives the Response and begins to parse it for display.
    1. The HTML body will include links to CSS, JS and images. All of these will trigger additional calls back to servers to retrieve those bits
  6. The browser layout engine will start to assemble the final page for display.
    1. CSS information may alter the layout and look of the page
    2. JS and DHTML may alter the layout of the page
  7. The final page is assembled and rendered to the end user
  8. http://igoro.com/archive/what-really-happens-when-you-navigate-to-a-url/
  • code something from scratch in 3 hours, then explain my design and solution
  • the best thing that they had created as a programmer
  • I will usually ask for code samples before the interview, or look at what they have at github
  • "what's in your feed reader" who do you follow?" and "how do you keep up to date?"
  • Make two armies fight each other and output the result. Introduce an element of randomness".
  • "What is your go-to language or the language that you are most proficient in?" and then "What would you change about <that language>?"
  • Write a function that takes a function and two ints and applies it to the two ints.

Saturday, August 30, 2014

Interview Questions

  • Given an Array, replace each element in the Array with its Next Element(To its RHS) which is Larger than it. If no such element exists, then no need to replace. 
                i/p: {2,12,8,6,5,1,2,10,3,2}
                o/p:{12,12,10,10,10,2,10,10,3,2}
  • Your algorithms have become so good at predicting the market that you now know what the share price of Wooden Orange Toothpicks Inc. (WOT) will be for the next N days. Each day, you can either buy one share of WOT, sell any number of shares of WOT that you own, or not make any transaction at all. What is the maximum profit you can obtain with an optimum trading strategy?
  • Given a list of integers, your task is to write a program to output an integer-valued list of equal length such that the output element at index 'i' is the product of all input elements except for the input element at 'i'.
                 i/p: {1,2,3}
                o/p:{6,3,2}    

  • Given a sorted array with duplicates and a number, find the range in the form of (startIndex, endIndex) of that number. 

           find_range({0 2 3 3 3 10 10}, 3) should return (2,4).
           find_range({0 2 3 3 3 10 10}, 6) should return (-1,-1).
          The array and the number of duplicates can be large.


  • There is an array of 3-tuple, in the form of (a, 1, 5). The first element in the tuple is the id, the second and third elements are both integers, and the third is always larger than or equal to the second. Assume that the array is sorted based on the second element of the tuple. Write a function that breaks each of the 3-tuple into two 2-tuples like (a, 1) and (a, 5), and sort them according to the integer.  
           E.g. given (a, 1, 5), (b, 2, 4), (c, 7, 8), output (a, 1), (b, 2), (b, 4), (a, 5), (c, 7), (c, 8).


Problem Solving Strategies

  1. Use Look-up Dictionary
  2. Use Stack, Queue
  3. User Recursion
  4. Use Binary Operators
  5. Saving previous results ( Dynamic programming)
  6. Throw exception for invalid inputs
  7. In place for memory optimization and store results in memory for processing speed optimization.

Friday, August 29, 2014

Coding principles

  1. Always private unless you are absolutely sure that you need public method.
  2. Deployment components sequence. Can update in one component breaks other component?
  3. Does deployment involves down time?
  4. what if the code run millions of times?

Thursday, August 28, 2014

Distributed software

  1. Load Balancer:  the load balancer just forwards the requests to the backend machines, which actually "process" the requests, receives the responses from the backend machines and sends them back to the client.
  2. Caching:
  3. Cluster: A computer cluster consists of a set of loosely connected or tightly connected computers that work together so that in many respects they can be viewed as a single system.
  4. Partition:
  5. Parallelization: means attacking a problem in a way that makes it easy to add more resources for solving it
  6. Caching:caching is easy, purging the caches when updates are needed is hard.
  7. Scalable code essentially means you solve problems such that your code is able to produce the desired output if the problem scales to a problem of millions or billions.
  8. Scale out: add more computers.
    Scale up: make each computer more powerful (add more CPUs, memory, storage, worker threads, etc) Map-Reduce operations tend to work best with the scale out approach. Virtualization benefits from scale up, but only to some degree.
Load Balancing