Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optamized code #258

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

optamized code #258

wants to merge 1 commit into from

Conversation

Anshv9616
Copy link

Use const string& in the Loop: This avoids unnecessary copies when iterating through the input vector.

String Key Construction: Instead of using a separate variable to create the key, we can directly construct it in a single loop. This is more straightforward and avoids potential confusion.

Reserve Space for the Result: By reserving space for the ans vector, we can reduce the number of reallocations that might occur as we push back results.

Move Semantics: When adding the grouped strings to the result, using move transfers ownership without copying, which can improve performance when dealing with larger strings.

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.

1 participant