Microsoft Interview Report
- 0of 0 votes
AnswersYou are tasked with migrating data between two systems that store movie metadata. The first system, which you are to use as input, keeps their movie metadata in the following structure:
MovieName ContributorType ContributorName
Pulp Fiction Director Quentin Tarantino
Pulp Fiction Actor John Travolta
Pulp Fiction Actor Samuel L. Jackson
Titanic Director James Cameron
The second system, which you are to output to, uses the following object for movie information:class MovieInformation { public string Name { get; set; } public string Director { get; set; } public List<string> Actors { get; set; } }
The first system provides an IDataReader that lets you access their data. Their data is always sorted on MovieName. You can call Read on the IDataReader to move the cursor to the next entry, and you can call GetString on the IDataReader to get the movie name, contributor type, and contributor name. For example, with the above data, if you were to call:
MovieDataReader dataReader = new MovieDataReader(); int movieNameOrdinal = dataReader.GetOrdinal( "MovieName" ); int contributorTypeOrdinal = dataReader.GetOrdinal( "ContributorType" ); int contributorNameOrdinal = dataReader.GetOrdinal( "ContributorName" ); while ( dataReader.Read() ) { string movieName = dataReader.GetString( movieNameOrdinal ); string contributorType = dataReader.GetString( contributorTypeOrdinal ); string contributorName = dataReader.GetString( contributorNameOrdinal ); }
Then at the end of the first iteration of this while loop, movieName would be “Pulp Fiction”, contributorType would be “Director” and contributorName would be “Quentin Tarantino”.
The second system provides a single method for posting movie information to their DB. This method should only ever be called once per movie:class MovieInformationDatabase { public void SaveMovieInformation( MovieInformation information ) { } }
Implement a method that migrates all of the data from the first system to the second system
- JSDUDE March 14, 2015 in United States for Cloud + Enterprise| Report Duplicate | Flag | PURGE
Microsoft Software Developer Algorithm - 0of 0 votes
AnswersIdentify the flaws / limitations in the following ConvertToNumber method:
- JSDUDE March 14, 2015 in United States for Cloud + Enterprisepublic static bool ConvertToNumber(string str) { bool canConvert = false; try { int n = Int16.Parse(str); if (n != 0) { canConvert = true; } } catch (Exception ex) { } bool retval = false; if (canConvert == true) { retval = true; } return retval; }
| Report Duplicate | Flag | PURGE
Microsoft Software Developer Debugging - 1of 1 vote
AnswersYou are tasked with implementing a method that returns the lowest possible number that could be generated after removing n characters from a string of digits. The method signature should look like:
public static string GenerateLowestNumber(string number, int n)
Where the number parameter is a string that contains a number (e.g. “4205123”), and the n parameter represents the number of characters to remove from the string. The goal of this method is to return the lowest number that can be generated by removing n characters from the number provided while keeping the positions of the remaining characters relative to each other the same (i.e. the method should remove n characters from the string, but it cannot re-order the characters).
- JSDUDE March 14, 2015 in United States for Cloud + Enterprise
For example, if number is “4205123” and n is 4, the lowest possible number that can be generated after removing any 4 characters is “012”. If number is “216504” and n is 3, the lowest possible number that can be generated after removing 3 characters is “104”.| Report Duplicate | Flag | PURGE
Microsoft Software Developer Algorithm String Manipulation