| |

VerySource

 Forgot password?
 Register
Search
View: 3466|Reply: 24

Interview questions, not done

[Copy link]

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 Pakistan

Post time: 2020-1-15 23:00:02
| Show all posts |Read mode
public class Test1 {
    static int k = 0;
; static final String [] s = {"1", "2", "3", "4", "5"};
    public static void getOne (String ret, int pos) {
        if (pos> = 4) {
            System.out.println (ret);
           k = k + 1;
            return;
        }
        for (int i = 0; i <s.length; i ++) {
            ret + = s [i];
            getOne (ret, pos + 1);
            ret = ret.substring (0, pos-1);
        }
    }
    public static void main (String [] args) {
        String num = "";
        getOne (num, 1);
        System.out.println (k);
    }
}
If I only get 5th and 4th place, what should I do?
Reply

Use magic Report

1

Threads

21

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 China

Post time: 2020-1-20 16:00:02
| Show all posts
if (ret.charAt (0) == '5') {System.out.println (ret);}
Reply

Use magic Report

1

Threads

51

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-1-20 17:18:01
| Show all posts
if (ret> = 10000) {System.out.println (ret);}
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-20 21:18:02
| Show all posts
for (int i = 0; i <s.length; i ++) {
        // Add a sentence
        if (i! = 3)
            ret + = s [i];
            getOne (ret, pos + 1);
            ret = ret.substring (0, pos-1);
        }
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-20 21:36:01
| Show all posts
Is it fourth?
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-1-25 09:45:01
| Show all posts
Yes, four people don't
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-1-25 10:09:01
| Show all posts
No. 4
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-1-25 11:27:01
| Show all posts
And if you can describe your thoughts, it would be the best, thank you
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-27 11:18:01
| Show all posts
You describe the problem first ...
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-1-27 17:36: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
Give a few digits
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