Fragen im Vorstellungsgespräch bei Allscripts: They had two coding exercises... |

Frage im Vorstellungsgespräch

Associate Software Engineer-Vorstellungsgespräch Raleigh, NC (Vereinigte Staaten von Amerika)

They had two coding exercises at the end. First was a warm

  up: reverse a string. i.e. "hello" should be "olleh" Second was pretty much the same exercise that was given here. You have ONE row of seats (single array) and you want to find the best one (best being the seat with the MOST empty seats at both the left and the right of it).

Antwort im Vorstellungsgespräch

2 Antworten


1) To reverse a string, they want you to use StringBuilder. Unlike using String variables which are immutable and create new String objects for every bit of manipulation (which is bad for memory allocation), StringBuilder takes the existing string object and modifies it without creating new ones, saving memory. In Java, there is a reverse() function, but they want you to do it without it.

2) Single array, iterated via for loop. True is filled false is vacant. If false, check seats to the left -- if any are false, add to leftCount. Same for the right side. leftCount plus rightCount equals total. Return the seat with the largest total.

Bewerber im Vorstellungsgespräch am 08.05.2014

Loop through the array, skipping taken seats, count empty seats left (reverse loop from current seat), count empty seats right (loop from current seat). I would also add a bonus if the seat has empty seats to immediate left and right of it.

Best Seat am 20.06.2015

Antwort oder Kommentar posten

Um dies zu kommentieren, bitte anmelden oder Konto anlegen.