Skip to content

Conversation

Srihari2222
Copy link
Collaborator

@neetcode-gh

  • Took 5 hours for this work.
  • Please review it.

Can you suggest the complexity for the problem "Design twitter", as it comes under heap category but the sorting solution also passes greatly for this problem?

Copy link
Owner

@neetcode-gh neetcode-gh left a comment

Choose a reason for hiding this comment

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

Looks good, minor change requested


* Time complexity: $O(m)$
* Space complexity: $O(m)$
* Space complexity: $O(1)$
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe i'm mistaken, but shouldn't the space complexity remain O(m)?

Oh, because the character set is 26. Can we add a note that this is because we only store a limited amount of values in the heap, like in: 7a6051c

Someone asked me a question about this the other day so i thought it was worth clarifying.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The space complexity is O(1) because we store almost 26 elements only in any data structure.

It is a good idea to add that note. I will do that for all articles when I am adding the "Swift" code.

@neetcode-gh neetcode-gh merged commit df08b81 into neetcode-gh:main Nov 23, 2024
@Srihari2222 Srihari2222 deleted the develop_hints branch November 23, 2024 10:59
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.

2 participants