Algorithm for recording a written examination interview question and an algorithm for the written examination question

Source: Internet
Author: User

Algorithm for recording a written examination interview question and an algorithm for the written examination question

It's almost the end of the year. Considering some situations and the fact that there are not so many business jobs now, the idea of wanting to learn more in technology suddenly gave rise to the idea of changing jobs, A good company Hr told me that they were recruiting people, so I secretly gave a resume. A few days later, she gave me a pen question. I saw an algorithm question, this is my biggest headache. I have no objection to the interview algorithm, but I feel that many employers still have to go to the interview based on their own business level, and recruit people suitable for the company's business processing, this is a relatively practical and developmental talent. When you come up with some very advanced algorithms for an interview, I feel that you need to see if your budget for recruiting people can meet the requirements for answering these questions. Do you need such profound technical support for your current business, at the same time, is it possible to give some popular programmers with low levels, such as me! Next I will list the interview questions and ask the experts in the school to solve them. I am eager to learn and want to communicate technically, because I am really not good at algorithms and I am eager to ask for advice, I want to learn more in this area.

30 minutes required
Programming languages are not limited, and small syntax errors are allowed;
Write a simple programming idea before the program;
1. Compile a function and exchange two numbers directly without any temporary variables.
2. Using arrays to implement a queue with a capacity of n requires that the time complexity of the incoming and outgoing queues be O (1 ).
3. Write a function and find the minimum m of the n numbers, where m <n. The time complexity of the algorithm is provided.

Here is the answer I sent to them.

Class Program {static void Main (string [] args) {// The first question int numA = 321; int numB = 8765; numA = numA ^ numB; numB = numB ^ numA; numA = numA ^ numB; Console. writeLine (numA); Console. writeLine (numB); // The second question var n = 100; var arr = new string [n]; var index = 0; var last = 0; // Action in the queue <string> push = s => {var nIndex = index + 1; nIndex = n? 0: nIndex; if (nIndex = last) {Console. writeLine ("queue full"); return;} arr [index] = s; index = nIndex;}; // output queue Func <string> pop = () ==>{ string result; if (index = last) // No data in the queue {result = null;} result = arr [last]; last ++; last = n? 0: last; return result;}; push ("AAA"); push ("BBB"); push ("CCC"); push ("DDD"); Console. writeLine (pop (); Console. writeLine (pop (); Console. writeLine (pop (); Console. writeLine (pop (); // the complexity of the Third-question algorithm O (n) because the time relationship currently only supports positive integers int [] arrInt = new [] {1, 2, 4, 6, 8, 9, 4, 2, 4, 7, 9}; int n1 = arrInt. length; Func <int, int []> func = m => {var max = 0; foreach (var item in arrInt) {max = max <item? Item: max;} var nArr = new bool [max + 1]; foreach (var item in arrInt) {nArr [item] = true ;} var result = new int [m]; var indexInt = 0; for (var I = 0; I <nArr. length; I ++) {if (nArr [I]) {result [indexInt] = I; indexInt ++;} if (indexInt = m) {break ;}} return result;}; var tmp = func (3); foreach (var item in tmp) {Console. writeLine (item);} Console. readKey ();}}

The above is the answer I gave in the past. The final result is not successful, but I cannot ask why with a thick face. After all, there is no technical personnel on the other side, I think there may be a problem with the algorithm in my third question. I took the space for another time, but I couldn't achieve it if I had repeated the output. I got a vulnerability. Haha, although the functional requirements are met, I do not know how to write better. I hope the experts in the garden can give me some advice on how to write the third question? Although I failed, I also wanted to find my own shortcomings in an interview. This question is not as good as my current level, so I want to solve better answers.


Interview question Algorithm

Static int [] zhaoQian = new int [7];
Public static string f (int a, int B)
{
Int c = B-;
String s = "the payment amount is insufficient! ";
If (c> 0)
{
ZhaoQian [0] = c/100;
ZhaoQian [1] = c %100/50;
ZhaoQian [2] = c %50/20;
ZhaoQian [3] = c %20/10;
ZhaoQian [4] = c %10/5;
ZhaoQian [5] = c %5/2;
ZhaoQian [6] = c % 2;
}
Else
{
Return s;
}
S = "retrieve money" + c. toString () + "RMB" + zhaoQian [0]. toString () + "Zhang; 50 RMB" + zhaoQian [1]. toString () +
"Zhang; 20 RMB" + zhaoQian [2]. ToString () + "Zhang; 10 RMB" + zhaoQian [3]. ToString () +
"Zhang; quintuple" + zhaoQian [4]. ToString () + "Zhang; two yuan" + zhaoQian [5]. ToString () +
"Zhang; "+ zhaoQian [6]. ToString () + "Zhang ";
Return s;

}
Public static void Main ()
{
Console. Write (f (123,600 ));
Console. Read ();
}

An algorithm question, an interview Test Question

Three candidates are selected, and the most three are presidents. I'm not sure.

Related Article

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.