Alibaba 2015 online R & D Engineer (Part)

Source: Internet
Author: User

Today, LZ went to Alibaba's online test and made a piece of soy sauce. Due to the limited level of LZ, the time was too short for him. I will share with you the notes below. There are 20 multiple-choice questions in total, and the top 10 questions are captured in the figure. It is too time-consuming to cut back the question. I wrote down two questions with my memory. Additional questions are recorded.

Multiple choice questions

Question 1st:

Question 2nd:


Question 3rd:


4th questions


Question 5th:


Question 6th:


Question 7th:


Question 8th:


Question 9th:


Question 10th:


Recalled question (one or two of the 11-20 questions)

1. A museum enters at the speed of 20 people per minute. On average, each person stays for 20 minutes. How many people do the museum need to accommodate at least?

A.100 B .200 c.300 d.400 e.500)

2. There is a binary tree. (the specific question cannot be clearly recorded. It mainly refers to the first and middle orders, and the last order)

Question 1

Given a query and a text, both consist of lower-case letters. It is required to find the length of the longest consecutive letter sequence that appears continuously in the query in the same order in text. For example, if the query is "acbac" and the text is "acaccbabb", the "CBA" in the text is the longest sequential letter sequence that appears in the query. Therefore, the returned result must be 3 characters long. Pay attention to program efficiency. (The answer is only the answer during the exam)

Package COM. wj; public class alitest {public static voidmain (string [] ARGs) {string query = "acbac"; string text = "acaccbabb "; // call the findcls method to calculate the findlcs (query. tochararray (), text. tochararray ();} public static voidfindlcs (char [] query, char [] Text) {string result = ""; // receives the result string int M = query. length; int n = text. length; int [] [] C = newint [m] [N]; int max = 0; int maxposx = 0; For (INT I = 0; I <m; I ++) {for (Int J = 0; j <n; j ++) {If (Query [I] = text [J]) {If (I = 0) | (j = 0) {C [I] [J] = 1 ;} else {C [I] [J] = C [I-1] [J-1] + 1;} If (C [I] [J]> MAX) {max = C [I] [J]; maxposx = I ;}} else {C [I] [J] = 0 ;}}} for (INT I = maxposx-MAX + 1; I <= maxposx; I ++) {result + = Query [I];} system. out. println ("Longest sequence:" + result); // output sequence system. out. println ("the longest sequence length is:" + max); // The length of the output sequence }}


Question 2

Write a function and input a binary tree. each node in the tree stores an integer. The function returns the absolute value of the difference between the two nodes with the greatest difference in the binary tree. Pay attention to program efficiency. (The answer is only the answer during the exam)

Int absmax (binarytree root) {queue <binarytree> btree = new queue <binarytree> (); binarytree P = new binarytree (); binarytree q = new binarytree (); btree. add (Root); // element into the queue int max = btree. peek (). getdata (); // Max and Min initialize int min = btree. peek (). getdata (); While (! Btree. isempty () {P = btree. Poll (); // element if (! P. islchild () // islchild () determines whether the left child exists. If yes, the btree. Add (P. getlchild (); If (! P. isrchild () btree. add (P. getrchild (); If (btree. isempty () {// if no element exists in the queue, it is directly compared with Max and min, and INT temp = P is returned. getdata (); // get the node value if (max <temp) max = temp; elseif (min> temp) min = temp; return ABS (max-min );} Q = btree. poll (); // if there are other values in the queue, the node is out of the queue and put into the queue if (! Q. islchild () // islchild () determines whether the left child exists. If yes, the btree. Add (Q. getlchild (); If (! P. isrchild () btree. add (Q. getrchild (); If (Q. getdata ()> = P. getdata () {// the value of the first Q node is compared with the value of the P node. The values of limit and Max are compared. The values of small and min are compared, to reduce the number of comparisons if (max <q. getdata () max = Q. getdata ();} else {If (min> P. getdata () {min = P. getdata () ;}} return ABS (max-min); // returns the absolute value of the difference between Max and min}

Question 3

What is the difference between the wait () method and the sleep () method in Java?








Alibaba 2015 online R & D Engineer (Part)

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.