Monday, July 30, 2018

Leetcode 39: Combination sum

July 30, 2018

Introduction


It is a medium level algorithm called combination sum. But I felt that it is so hard to come out a solution with well-defined time complexity. All I can think about is brute force solution. I like to sort the candidate numbers and then brute force minimum value in the combination sum.

I have the idea but how to write a workable code. I really think about getting general ideas about the algorithm.

It is time to look into Leetcode discussion related to the algorithm. One of C# solutions is here to study.

My practice


I also like to write C# code this time to learn the algorithm again. I also wrote some analysis in the code, I like to help myself to understand the algorithm better this time.

Here is C# practice code in July 2018.

Here is C# practice code in June 2017.



My goal of research 


I came cross this algorithm last night, and I did spend over 10 minutes to think about the algorithm. I could not believe that I wrote a solution just one year ago. I was nervous, and I thought about a few things. I asked myself what is brute force solution. Let me sort the candidate first. What is the minimum number in combination? Can we brute force on this minimum number? How many steps to take to calculate all possible choice for a combination?

In order for me to get comfortable on the algorithm problem solving, I did look into and answer the question when I practice this time.


No comments:

Post a Comment