Last active
August 29, 2015 14:14
-
-
Save ik11235/814b7414b27f4fd25fd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PeacefulLine { | |
public: | |
string makeLine(vector<int> x) { | |
sort(x.begin(),x.end()); | |
int ans=0; | |
int cnt=1; | |
for (int i=1; i < x.size(); i++) { | |
if(x[i-1]==x[i]) | |
{ | |
cnt++; | |
ans=max(cnt,ans); | |
} | |
else | |
cnt=1; | |
} | |
if(ans<=(x.size()+1)/2) | |
return "possible"; | |
else | |
return "impossible"; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment