2017 Alibaba algorithm Engineer online test _ Internship Online test questions

Source: Internet
Author: User

2017/3/22
Today, Alibaba algorithm engineers online Pen test questions, time is tight, only 40 minutes, and not have time to tune out, when it is, this is later compiled through the code, posted here to facilitate reference learning. The
has n positive integers (less than 1 billion per number), representing them as strings. For each string s, can flip to the new string s ', such as "1234" can be flipped into "4321".
Now, connect the n strings in any order to a character token, and each string can choose whether or not to flip. In the word token, start at any point, traverse the entire loop, and get a long integer. Excuse me, how can I get the largest long integer.

arr = raw_input () arr_l = Arr.split (') N = Len (arr_l) print (n) for I in Range (n): str_l = L En (Arr_l[i]) if arr_l[i][0] < ARR_L[I][STR_L-1]: New = ' for index in range (str_l): Ne w = new+arr_l[i][str_l-1-index] arr_l[i] = New for i in Range (N): to J in range (I, N): If arr_l[i][ 0] < Arr_l[j][0]: temp = arr_l[i] arr_l[i] = arr_l[j] arr_l[j] = temp Elif Arr_l[i][0] = = Arr_l[j][0]: Len1 = Len (arr_l[i]) Len2 = Len (arr_l[j]) if Len1 < Len 2:l = Len1 Else:l = Len2 for k in range (1, L): I
                    F Arr_l[i][k] < Arr_l[j][k]: TEMP1 = arr_l[i] arr_l[i] = arr_l[j] ARR_L[J] = Temp1 break ans = ' to I in Range (N): print (arr_l[i]) Ans = Ans+arr_l[i] P Rint (Ans) 

Input:
123 253 789
Output:
3
987
352
321
987352321

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.