Monday, February 12, 2018

Smallest substring containing all unique keys

Feb. 12, 2018

Introduction


It is so much fun to play mock interview. I met the same peer fifth time.

After the mock interview, I gave the algorithm to the peer to solve, and I am busy working on my hackerrank contest algorithm.

Last minute, after ten minutes to give out the algorithm, I found out that I made a mistake on the constraint. The array should include non-negative elements only. And the peer came out the solution I could not understand.

The problem is to find a continuous subarray with the given sum, and then the solution is to apply dynamic programming using O(n) time to get the prefix sum from left to right, and then use two pointer techniques on an ascending array.


Code review


I chose to skip my algorithm, and asked to study the peer's solution. Here is C# solution I like to review and then rewrite later.






No comments:

Post a Comment