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

Create majorityElementHashhmap.java #158

Merged
merged 1 commit into from
Oct 11, 2023
Merged

Create majorityElementHashhmap.java #158

merged 1 commit into from
Oct 11, 2023

Conversation

Diptigit11
Copy link
Contributor

HashMap has ability to efficiently store and manage data by associating keys with values and it also improves the Time Complexity. The question which is solved in the provided java code is a very known question and it builds a strong foundation for the topic hashmap. Question follows:
Given an Array of size n, find all the elements that appear more than n/3 times Array={1, 3, 2, 5, 1, 3, 1, 5, 1 }.
Using two nested for loops to solve this problem would result in a less efficient solution with a time complexity of O(n^2), making it slower for large input arrays compared to the HashMap-based solution, which has a time complexity of O(n). This code uses a HashMap to efficiently count how many times each unique element appears in an array. It then checks if any of these elements appear more than one-third of the total elements in the array and prints them if they do. This demonstrates how HashMaps are valuable for tracking and analyzing data efficiently in real-world programming scenarios.

 HashMap has ability to efficiently store and manage data by associating keys with values and it also improves the Time Complexity. The question which is solved in the provided java code is a very known question and it builds a strong foundation for the topic hashmap. Question follows:
 Given an Array of size n, find all the elements that appear more than n/3 times Array={1, 3, 2, 5, 1, 3, 1, 5, 1 }.
Using two nested for loops to solve this problem would result in a less efficient solution with a time complexity of O(n^2), making it slower for large input arrays compared to the HashMap-based solution, which has a time complexity of O(n). This code uses a HashMap to efficiently count how many times each unique element appears in an array. It then checks if any of these elements appear more than one-third of the total elements in the array and prints them if they do. This demonstrates how HashMaps are valuable for tracking and analyzing data efficiently in real-world programming scenarios.
@Diptigit11
Copy link
Contributor Author

Diptigit11 commented Oct 9, 2023

#130 Please review and merge this pull request under hacktoberfest-accepted label .Thank You

@sujana-kamasany sujana-kamasany added Hacktoberfest-Accepted Make your Pull Request for Hacktoberfest 2023 good first issue Good for newcomers labels Oct 11, 2023
@sujana-kamasany sujana-kamasany merged commit 526be11 into sujana-kamasany:main Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Hacktoberfest-Accepted Make your Pull Request for Hacktoberfest 2023
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants