We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Picking Numbers
- Discussions
Picking Numbers
Picking Numbers
Sort by
recency
|
207 Discussions
|
Please Login in order to post a comment
I'm seeing a lot of dictionaries in the comments, but because the constraints declare the numbers are within 1 - 100, we can use a fast counting array, here's my C# solution.
Problem: [1 ,2, 2, 3, 1, 2] Incorrect: Subsets [1,2,2,3] and [1,2] My output: 4 Expected output: 5
Correct: because 3 doesn't fullfil condition to be in the same set as number 1 sorted: [1,1,2, 2, 2,3] Subsets [1,1,2,2,2] and [3] My output: 5 Expected output: 5
I interpreted this several other ways than what the problem statement meant before checking here lol...
question asks "longest subarray" that should be continuous elements from the original array, so not allowed to change order. Thats what the example shows. Then on input: 1 2 2 3 1 2 expected answer: 5.
Thats for sure wrong. Question worded incorrectly. After sorting the inputarray my sollution passes. So the question means SUBSET: any combination of elements regardless of order or position
Rust best solution
If you’re looking for solutions to the 3-month preparation kit in either Python or Rust, you can find them below: my solutions