Skip to content

Create count_pair_with_given_sum.cpp#83

Open
Tusharr0305 wants to merge 1 commit into
ignacio-chiazzo:masterfrom
Tusharr0305:patch-1
Open

Create count_pair_with_given_sum.cpp#83
Tusharr0305 wants to merge 1 commit into
ignacio-chiazzo:masterfrom
Tusharr0305:patch-1

Conversation

@Tusharr0305

Copy link
Copy Markdown

Added Subarray problem

@ignacio-chiazzo ignacio-chiazzo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hey! Thanks for contributing!

This repository is only for solutions in Javascript. We are also following a specific format.

I'd be happy to accept this problem but in Javascript.

Thanks again for contributing.

@hot9cups hot9cups left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Additionally to what Ignacio mentioned, I would also request a change in the solution when you do translate to javascript.
You have an O(N^2) solution, but I believe you can achieve an O(N) solution using a Map/Dictionary that stores the frequency of every number in the array, and then traversing the map to get count of pairs.

@Tusharr0305

Copy link
Copy Markdown
Author

Okay will share 0(N) solution soon.

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