Facebook online puzzle online test-Questions and answers

Source: Internet
Author: User

Although FB has not had any great hopes recently, it is worth all efforts to prepare it. The preparation process will make yourself powerful.

The online puzzle question provided by HR last week is much simpler than imagined.

Online puzzle test should be a basic programming capability test for interviewee going into the interview process, using the submit platform is a third-party interview Street, interested students can go (https://www.interviewstreet.com/challenges/dashboard/#problems) register an account and try out the submit environment, which is similar to ACM but not exactly the same.

HR gave me a pre-prepared account and password, and a connection. I logged in and started to do the problem. The Question Time is 70 minutes and there is only one question. Therefore, Do not be nervous and have enough time for the same interview.

I just want to reveal the interview questions to you (also welcome to contact FB ).

Question: Give a dictionary. All the words in the dictionary are three characters in alphabetical order. Now we need to select three strings from the dictionary: In the matrix composed of these three strings, vertical and oblique words (from 11 22 33 and 13 22 31) must be in the dictionary.

For example, data (data was fabricated later)

Input 1
Aaa
ABC
BAC
CAC
CCA

Output 1
Aaa
Aaa
Aaa

ABC
BAC
CCA

BAC
Aaa
CAC

CAC
Aaa
CAC
------------------------------------------------------------------

Intput2

AAC
ABC
Abe
Baa
BAC
Bfe
EAA
ECC
Fab

Output2:
Bfe
AAC
ABC

Although this question is very simple, it took 50 minutes to get through all the data. Enumeration + search. Enumerate all three strings in the dictionary (including their own duplicates), generate vertical and oblique strings, and then use binary search to find the dictionary.

By the way, let's share what I wrote at the time.Code:

# Include <stdio. h> # include <string. h> # define max_word_account 200 char wordlist [max_word_account] [4]; int nwords; int findword (char STR [], int nstartidx, int nendidx) {int nmiddle; int cmprst; while (nstartidx <= nendidx) {nmiddle = (nstartidx + nendidx)/2; cmprst = strcmp (STR, wordlist [nmiddle]); If (cmprst = 0) {return nmiddle;} else if (cmprst =-1) {nendidx = nmiddle-1;} else {nstartidx = nmiddle + 1;} RET Urn-1;} bool testlefttorightdiagonals (int I, Int J, int K) {char strnewword [4] = {0 }; strnewword [0] = wordlist [I] [0]; strnewword [1] = wordlist [J] [1]; strnewword [2] = wordlist [k] [2]; int nwordloc = findword (strnewword, 0, nwords-1); If (nwordloc! =-1) {return true;} return false;} bool testrighttoleftdiagonals (int I, Int J, int K) {char strnewword [4] = {0 }; strnewword [0] = wordlist [I] [2]; strnewword [1] = wordlist [J] [1]; strnewword [2] = wordlist [k] [0]; int nwordloc = findword (strnewword, 0, nwords-1); If (nwordloc! =-1) {return true;} return false;} bool cangenerateword (int I, Int J, int K) {char strnewword [4] = {0}; int icol; int nwordloc; For (icol = 0; icol <3; icol ++) {strnewword [0] = wordlist [I] [icol]; strnewword [1] = wordlist [J] [icol]; strnewword [2] = wordlist [k] [icol]; nwordloc = findword (strnewword, 0, nwords-1 ); if (nwordloc =-1) {break;} If (icol = 3 & testlefttorightdiagonals (I, j, k) & testrighttoleftdiagon ALS (I, j, k) // test succeed for column {return true;} return false;} int main () {int iword = 0; while (scanf ("% s", wordlist + iword )! = EOF) // make Word List {iword ++;} nwords = iword; int I, j, k; char strnewword [4] = {0}; int icol, irow; int nwordloc; for (I = 0; I <nwords; I ++) {for (j = 0; j <nwords; j ++) {for (k = 0; k <nwords; k ++) {If (cangenerateword (I, j, k) {printf ("% s \ n ", wordlist [I], wordlist [J], wordlist [k]) ;}}}

In short, it gives me the feeling that online puzzle is a basic way to see if you will writeProgramFor example, binary search may be a collection point. So basicAlgorithmThere should be no problem with this process. The interview process is still in progress, and the monks are still practicing algorithms to prepare for the next interview.

It's too early to share other experiences. If someone is on FB, you are welcome to join us ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.