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.
1. Every element is unique: No repeats
i.e. A set cannot have the element "4" twice
2. Every element is the previous element +1, an increment
i.e. {1,2,3} is valid. 1+1=2, 2+1=3
i.e. {1,4,5} is not valid because 4!=1+1
What the Problem is asking:
Output the size of the maximized "minimum set."
Sounds, kind of weird, but I'll try to clarify with an example.
EX:{1,2,3,5,6,7}
Some Potential outputs (I won't list them all):
-{1},{2},{3},{5},{6},{7} The size of the minimum list is 1
-{1,2},{3},{5,6,7} The size of the minimum list is 1
-{1,2,3},{5,6,7} The size of the minimum list is 3
Your answer is 3 because it's the maximized size of the "minimum set"
Things you might want to know:
-The problem states "The absolute value of skill levels will not exceed 10^9", that just means that each element will be an int.
-For some weird reason 0 is a value. Just add a line
if(N==0)
cout<<"0";//and continue the loop.
else
solveProblem();
Hints:
1. Problem you may have:
~Repetative numbers and knowing when to stop a list~
{0,1,2,3,4,4,5,6,7}//notice 4 is in the list twice
Answer 4:{0,1,2,3,4} and {4,5,6,7}
Wrong answer: {0,1,2,3,4,5,6,7},{4}, which is 1
~Repetative numbers and recognizing how many more are left~
{1,1,1,2,2,2,3,3,3,4,4,4,5,5,5}//Notice repetition
Answer 5: {1,2,3,4,5}, {1,2,3,4,5}, and {1,2,3,4,5}
Wrong answer:{1},{1},{1},{2},{2},{2},...,{5},{5},{5}
~Unsorted input~
{4,2,5,7,6,1,0}
Answer 3:{0,1,2} and {4,5,6,7}
Data Structure are your friends:
-Think Hashmaps, Sets, Priority list,etc. This problem can be approach in a few different ways.
-Keep track of how many times an element shows up
Team Formation
You are viewing a single comment's thread. Return to all comments →
This problem is weird.
Let me try to explain it:
you need to find sets with the property below
What the Problem is asking:
Things you might want to know:
-The problem states "The absolute value of skill levels will not exceed 10^9", that just means that each element will be an int.
-For some weird reason 0 is a value. Just add a line
Hints: 1. Problem you may have:
Data Structure are your friends: