My first written test

Source: Internet
Author: User

Today is my first renewal. The recruitment unit is Lianxin Yong.Yi, this company is recruiting at our school. Our teacher told us in advance that we are working on a small commercial tea website project introduced to us by our teacher, I didn't take it seriously. I felt good about myself. I had to renew it today. I was still working on that website last night and went to bed at half past two. I felt very confused from, when I got up and took a bath, I woke up a lot and rushed to prepare a very simple resume.

First, the company gave them an introduction, then the written examination, the written examination, and then the interview. I thought of its solution as soon as I saw the first question, and then I wrote it in a confused way. In fact, this written examination mainly involves this question and the next question. This question is originally very confident, and the second question is not confident. I am confident that I have done wrong, not to mention confidence.

In general, it should be because you are not prepared, have no good rest, and have poor basic knowledge.

Below are the written questions:

Question 1: Write A method. Its function is to enter a string of characters to remove the repeated characters in the string.

I won't talk about the original solution. My current solution is:

View code

 1  Using System;
2 02 . Using System. Collections. Generic;
3 03 . Using System. LINQ;
4 04 . Using System. text;
5 05 .
6 06 . Namespace Leleapplication20
7 07 .{
8 08 . Class Program
9 09 .{
10 10 . Static Void Main (String [] ARGs)
11 11 .{
12 12 . String str1 = string. empty;
13 13 . Console. Write ( " Enter a string of characters: " );
14 14 . Str1 = console. Readline ();
15 15 . Str1 = alike (str1 );
16 16 . Console. writeline ( " Remove the string from the complex: {0} " , Str1 );
17 17 . Console. Readline ();
18 18 .}
19 19 .Static String alike (string str1)
20 20 .{
21 21 . String STR = "" ;
22 22 . For ( Int I = 0 ; I <str1.length; I ++)
23 23 .{
24 24 . // If str1 [I] is not in the position from 0 to I of str1,-1 is returned, and it is added to the STR string.
If (Str1.indexof (str1 [I], 0 , I) =- 1 )
25 25 . Str + = str1 [I];
26 26 .}
27 27 . Return STR;
28 28 .}
29 29 .}
30 30 .}

The following are some solutions that I have posted on the csdn Forum:

User: huangwenquan123

View code

 1           Static   String Alike (String Str)
2 {
3 Bool [] Arr = New Bool [ 52 ];
4 String Result = String . Empty;
5 Int Temp;
6 Foreach ( Char C In Str)
7 {
8 Temp = c- ' A ' > = 32 ? C- ' A ' + 26 : C- ' A ' ;
9 If (! Arr [temp])
10 {
11 Result + = C. tostring ();
12 Arr [temp] = True ;
13 }
14 }
15 Return Result;
16 }

Netizen: hengxinyi

View code

 1   Static   Void Main ( String [] ARGs)
2 {
3 List < Char > List = New List <Char > ();
4 String STR = console. Readline ();
5 For ( Int I = 0 ; I <Str. length; I ++)
6 {
7 If (! List. Contains (STR [I])
8 {
9 List. Add (STR [I]);
10 }
11 }
12 Foreach ( Char N In List)
13 {
14 Console. writeline (N );
15 }
16 Console. Readline ();
17 }

Everyone has a better speed.Algorithm? I hope you can share it with me.
Question 2: Three tigers are represented by aa bb cc, each of which is composed of a mother tiger and a child tiger. The three Tigers take a boat from the river to the river, this ship can only take two tigers at a time. If either of them is not with the tigers, they will be eaten by other tigers.

I did not announce the solution to this question. I was planning to have 10 netizens reply and announce it again. The first reply from the netizen xhloo will announce the solution:

View code

1 1, AA-> right bbcc AA
2 2, A-> left bbcca
3 3, BC-> right ABC
4 4, C-> left ABCC AB
5
6 5, AB-> right CC AABB
7 6, BB-> left bbcc AA
8 7, BC-> right BC AABC
9 8, A-> left ABC

Who can help me use C #CodeWrite it out? I can't write this yet.

 

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.