Hot answers tagged

4

There are several inefficient elements in the implementation. Use a Set instead of an array for fast lookups The code uses uniqueIds to keep track of the ids seen so far. The uniqueIds.includes does a linear scan over the items in the array. Using a Set would make that constant time. Avoid repeated computations There are several repeated computations here: ...


3

There's some odd features to this code, even for a coding practice exercise. Python of course has a couple of list sorting techniques which you should absolutely use in normal circumstances. So accepting that you are doing this for practice, I wonder what the point of the duplicatelist is? Or indeed temp? Are these development fossils of some earlier process ...


1

Properties For the sake of simplicity let's assume your view model's properties are defined like this: public int? PriorityScore { get; set; } public string MName { get; set; } public string CName { get; set; } public string FName { get; set; } Compare Your Compare method can be simply implemented with the following one-liner: private const int ...


1

First of all, your code has an error. Once you do this.PriorityScore?.CompareTo(mod.PriorityScore), for a PriorityScore that I assume it's a Nullable int, for any null value you will get null, then casting to int will fail. Or if mod.PriorityScore is null, the CompareTo method will fail. Fixing that, if you return values from an if block, you don't really ...


1

From a short review asort is not a great name, sortedA could have been better? As mentioned by another user, it is bad practice to change lists you receive as a parameter You only us bi once. I would use b[i] in that one place for readability aj is not a great name, your two letter variables make your code hard to read Once you realize that you can just ...


Only top voted, non community-wiki answers of a minimum length are eligible