Interview questions are usually about the thought process and usually donβt care too much about language functions, but I could not resist publishing the version of VB.Net 4.0 anyway.
Effective can mean two different things. The first is "the fastest way to get the computer to complete the task," and the second is "what is the fastest that we can complete the task." They may sound the same, but the former may mean micro-optimizations, such as int vs short , starting timers to compare runtimes, and performing weekly settings for every millisecond from the algorithm. The second definition is how long it will take human time to create code that performs the task (I hope, in a reasonable amount of time). If code A is 20 times faster than code B, but code B takes 1/20 time to write, depending on the timer details (1 ms vs 20 ms, 1 week vs 20 weeks), each version can be considered "effective" ,.
Dim input = "abcdeeabc" Dim sort = "dfbcae" Dim SortChars = sort.ToList() Dim output = New String((From c In input.ToList() Select c Order By SortChars.IndexOf(c)).ToArray()) Trace.WriteLine(output)
source share