Skip to content

optamized code#258

Open
Anshv9616 wants to merge 1 commit intosachinsingh3232:mainfrom
Anshv9616:main
Open

optamized code#258
Anshv9616 wants to merge 1 commit intosachinsingh3232:mainfrom
Anshv9616:main

Conversation

@Anshv9616
Copy link
Copy Markdown

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