Skip to content

Added MapReduce Algorithm in Misc Folder. #4828

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

Merged
merged 6 commits into from
Oct 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Did formatting correctly
  • Loading branch information
aakiliqbal committed Oct 17, 2023
commit e6fcc14af9559f0e063ca9e65a74c93f3073cfd9
3 changes: 1 addition & 2 deletions src/main/java/com/thealgorithms/misc/MapReduce.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public static void main(String[] args) {
List<String> words = Arrays.asList("apple", "banana", "apple", "orange", "banana", "apple");

// Map step
Map<String, Long> wordCounts = words.stream()
.collect(Collectors.groupingBy(w -> w, Collectors.counting()));
Map<String, Long> wordCounts = words.stream().collect(Collectors.groupingBy(w -> w, Collectors.counting()));

// Reduce step
wordCounts.forEach((word, count) -> System.out.println(word + ": " + count));
Expand Down