[C++/Python] 2 solutions - Clean & Concise - Follow-up: K-Sum
✔️ Solution 1: HashSet
The idea is to use HashSet to track past elements.
We iterate the combinations of nums[i], nums[j], nums[k], and calculate the last numbe
**✔️ Solution 1: HashSet**
- The idea is to use `HashSet` to track past elements.
- We iterate the combinations of `nums[i]`, `nums[j]`, `nums[k]`, and calculate the last number by `lastNumber = target - nums[i] - nums[j] - nums[k]`. 
- We check if `lastNumber` is existed the past by checking in the HashSet, if existed, then it form a `quadruplets` then add it to the answer.

Credit @archit91 for providing C++ version.
<iframe src="https://leetcode.com/playground/BsiPbnLs/shared" frameBorder="0" width="100%" height="500"></iframe>

Complexity:
- Time: `O(N^3)`
- Extra Space (Without count output as space): `O(N)`
---
**✔️ Solution 2: Sort then Two Pointers**
- Sort `nums` in increasing order.
- We fix `nums[i], nums[j]` by iterating the combination of `nums[i], nums[j]`, then the problem now become to very classic problem **[1. Two Sum](https://leetcode.com/problems/two-sum/)**.
- By using two pointers, one points to `left`, the other points to `right`, `goal = target - nums[i] - nums[j]`.
	- If `nums[left] + nums[right] == goal`
		- Found a valid quadruplets
	- Else if `nums[left] + nums[right] > goal`
		- Sum is bigger than goal, need to decrease sum by `right -= 1`
	- Else:
		- Increasing sum by `left += 1`.

<iframe src="https://leetcode.com/playground/Dz7F3Sqw/shared" frameBorder="0" width="100%" height="650"></iframe>

Complexity:
- Time: `O(N^3)`
- Extra Space (Without count output as space): `O(sorting)`

---
**✔️ Follow-up question: Calculate K-Sum?**

<iframe src="https://leetcode.com/playground/KUgSSN93/shared" frameBorder="0" width="100%" height="600"></iframe>

Complexity:
- Time: `O(NlogN + N^(k-1))`, where `k >= 2`, `N` is number of elements in the array `nums`.
- Extra space (Without count output as space): `O(N)`

If you think this **post is useful**, I'm happy if you **give a vote**. Any **questions or discussions are welcome!** Thank a lot.
['Two Pointers', 'C++', 'Python3']