A. Question and answer question
1. Are you familiar with palindrome? A string from the previous look and look back if the same, is a palindrome string. For example, "Shanghai tap water from the sea" is a palindrome string. Now our problem comes, to think of a number as a string and ask if it is a palindrome number? Such a simple topic is certainly not a problem for you who want to be a Xiaomi engineer. But a reminder: the higher the score, the less time complexity and less space complexity.
C++:
BOOL Ispalindromenumber (Long num)
Java:
Boolean ispalindromenumber (Long num)
Example: 12321-True
3-True
133434-> false
2. The problem of finding two polynomial products I believe that we often encounter in high school, it is such a problem:
Pa=an*x^n + an-1*x^ (n-1) + ... + a1*x + a0
Pa=bm*x^m + bn-1*x^ (m-1) + ... + b1*x + b0
Among them, an, an-1, ..., A0, BM, Bm-1, ..., b0 are integers, range [-10000, 10000]. 0<=n, M <=1000.
The result of PA*PB is also a polynomial, ask you to program to solve this problem, you need to design how to represent a polynomial and write out two polynomial multiplication program.
C++:
String multiplypolynormial (const string&pa,const STRING&PB)
Java:
String Multiplypolynormial (String pa,string PB)
The PA and PB formats are all "( -3,5), (87,4), (93,3), (3,0)", which represents a polynomial: -3*x^5 + 87*x^4 + 93*x^3 + 3
Input is legal, except for numbers, the left and right brackets and commas have no other characters, and the power is arranged from high to low, and the output is required to be a standard format.
Package Com.mi.recruitment;public class Multiplypolynormial {public static void main (string[] args) {//TODO Auto-gener Ated method Stub System.out.println (Multiplypolynormial ("( -3,2), (n), (4,0)", "(4,2), (3,1), (5,0)")); public static string Multiplypolynormial (String pa,string PB) {string[] Paarray = pa.split ("\ \"), \ \ ("); string[] Pbarray = pb.split ("\ \"), \ \ ("); string[] Totall = new String[paarray.length*pbarray.length]; int k = 0; String result= ""; for (int i=0; i<paarray.length; i++) {String pa = paarray[i].replaceall ("\ \ (|\\)", ""); for (int j=0; j<pbarray.length; J + +) {String PB = Pbarray[j].replaceall ("\ \ (|\\)", ""); Totall[k] = (Integer.parseint ("Pa.split (") [0]) *integer.parseint (Pb.split (",") [0]) + "," + (Integer.parseint ( Pa.split (",") [1]) +integer.parseint (Pb.split (",") [1])); k++; }} for (int i=0, i<totall.length; i++) {for (int j=i+1; j<totall.length; J + +) {if (Totall[i]! = "" && t OTALL[J]! = "") {if (Totall[i].split (",") [1].Equals (Totall[j].split (",") [1])) {Totall[i] = (Integer.parseint (Totall[i].split (",") [0]) +integer.parseint (totall[ J].split (",") [0]) + "," + Totall[i].split (",") [1]; TOTALL[J] = ""; }}}} for (int i=0; i<totall.length; i++) {if (Totall[i]! = "") {result = result+ "(" +totall[i]+ "),"; }} return result.substring (0, Result.length ()-1); }}
3. Xiaomi internal each employee will have a dedicated work mailbox, the mailbox prefix is the name of the employee pinyin full spelling, such as Zhang Qiang's mailbox is [email protected], but at the same time there are many people with the same name in the company, in order to avoid each other to send the wrong mail, Engineers have thought of a rule to solve this problem, that is, in these same life, the first mailbox prefix for the name of the full spelling, the second entry of the mailbox prefix for the name of the spelling of the whole spell back plus "_a", the third entry for the name of the spelling of the whole after adding "_b", to the second analogy, please If there are 3 employees named Zhang Qiang in the company, their mailboxes are
[Email protected],[email protected],[email protected] The mailbox prefix is one of the employees in the company's important logo, the problem is: now Xiaomi to hold a full field zippered activities, require all employees must be lined up to go out, and, Some employees require that he must be in front of or behind someone, as the organizer of you, after receiving such a demand, how to give everyone to the satisfaction of the queuing method?
Java:
Class Requestitem
{
Public String member;
public Boolean Standfront; True indicates that you want to be in front of this person, false indicates that you want to be in the back of this person
}
Class Request
2015 Millet School recruit Technical pen question