Microsoft Interview Question for Software Developers

Country: Israel
Interview Type: Phone Interview

Comment hidden because of low score. Click to expand.
of 2 vote

Initiate random number with value 0 to n. get a number from this function and then swap this number with last number of array. then call the random fucntion with 0 to n-1... and swap the number with n-1 index and repeat the process.

- sandeepmnit35 July 10, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

you can use an array to shuffle songs.With the help of a pseudorandomgenerator,we generate random numbers from 1 to 100 whatever number comes up play that song and then continue the loop with 2 to n then 3 to n and so on whatever number comes up just swap it with the first number.

- Shivangi July 17, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

String[] songs = {"Muse - Dead Inside","Scorpions - Send Me An Angel",
            "RHCP - Californication","Scorpions - Wind of Change","Muse - Psycho",
            "Metallica - Fade to Black","Apple - Binary Symphony"};
            ArrayList <String> array = new ArrayList<>();
        System.out.println("UNSORTED LIST");
                for(int i=0;i<=100;i++) {
                    int randnum = (int) Math.floor(Math.random() * songs.length);
                    for (int i1=0; i1<=array.size(); i1++){
                        if (!array.contains(songs[randnum])){
                Set<String> seted = new TreeSet<>(array);
        Object[] objects = ((TreeSet<String>) seted).headSet(String.valueOf(((TreeSet<String>) seted).isEmpty())).toArray();
        System.out.println("SORTED LIST(ALPHABETICALLY)");
                for (int i = 0; i<objects.length; i++) {

- xidonett August 07, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
of 2 vote

I took 10 songs, you can take 100 :)

playlist = set(['song1', 'song2', 'song3', 'song4', 'song5', 'song6', 'song7','s8','s9','s10'])
for n in range(len(playlist)):
    print('Now playing...' + playlist.pop())
print('Playlist finish, if you want, i can solve this using OOP design')

- manmaybarot July 19, 2018 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More


CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More