| |

VerySource

 Forgot password?
 Register
Search
Author: 别叫我女生

Interview questions, not done

[Copy link]

0

Threads

57

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-28 04:09:02
| Show all posts
I do not understand the meaning
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-1-29 19:27:01
| Show all posts
Specify as a number, such as 1 2 3, I only need 3 digits which is 123 132 213 231 312 321
For example 1 2 I only need 2 digits is 12 21
Give a few digits
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-29 22:36:01
| Show all posts
Provide an idea, find the smallest (such as 123) and the largest (such as 321) in the number combination, and then output the number between them
Reply

Use magic Report

0

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

Post time: 2020-1-30 18:09:01
| Show all posts
Arrange them all,
Minimum and maximum, as long as the largest is selected each time is the largest, the smallest is selected the smallest is the smallest
Reply

Use magic Report

0

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-30 19:27:01
| Show all posts
import java.io. *;

public class Test {

public static void main (String [] args) throws Exception
{
Ranch
FileWriter out = new FileWriter ("result.txt");
int count = 0;
for (int i = 123; i <= 321; i ++)
{
String s = new String (i + ",");
if (s.indexOf ("4")> = 0)
{
continue;
}
else if (s.indexOf ("5")> = 0)
{
continue;
}
else if (s.indexOf ("6")> = 0)
{
continue;
}
else if (s.indexOf ("7")> = 0)
{
continue;
}
else if (s.indexOf ("8")> = 0)
{
continue;
}
else if (s.indexOf ("9")> = 0)
{
continue;
}
else if (s.indexOf ("0")> = 0)
{
continue;
}
else
{
count ++;
out.write (s, 0, s.length ());
}
}
System.out.println ("find:" + count);
out.close ();
}
}
Reply

Use magic Report

1

Threads

20

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-2-4 14:30:01
| Show all posts
The procedure is for someone else.

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class Test
{
    public static void main (String [] args) throws Exception
    {
String [] array = new String [] {"1", "2", "3"};
listAll (Arrays.asList (array), "");
    }

    public static void listAll (List candidate, String prefix)
    {
if (prefix.length () == 3)
{
System.out.println (prefix);
}
Ranch
for (int i = 0; i <candidate.size (); i ++)
{
List temp = new LinkedList (candidate);
listAll (temp, prefix + temp.remove (i));
}
    }
}

Take 3 digits as an example, set the list of elements to be retrieved to, and to display String as prefix
First traverse to fetch dates from candidate and add to prefix, one less for candidate and one more for prefix
In this way, recursive loops are the best choice.
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-7 12:45:01
| Show all posts
Bangding

The purpose of the question is to output several permutations and combinations, and then the fourth digit of each combination is not necessary?
Reply

Use magic Report

0

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-23 01:15:01
| Show all posts
ret + = s [i];
getOne (ret, pos + 1);
ret = ret.substring (0, pos-1);
The control logic is here, if you want to do special processing for some bits, do it here
You can draw a trick for each function call, knowing its internal principles, you can modify it arbitrarily.
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Germany

Post time: 2020-3-10 10:45:01
| Show all posts
Study! ~~~
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-3-14 20:30:01
| Show all posts
Thank you, let me see
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list