Skip to content

Conversation

@jhm9595
Copy link
Owner

@jhm9595 jhm9595 commented Dec 25, 2022

Time Complexity : O(NM)

int[] candidatesSort = new int[candidatesSize + 1];

for(int num : candidates) {
candidatesSort[num]++;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm personally against counting sort in almost any cases.

If you use counting sort, the space complexity will be dependent upon the maximum number, and this is not ideal.

I think a standard O(NlogN) sorting method would be enough in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants