File tree Expand file tree Collapse file tree 3 files changed +34
-31
lines changed
src/test/java/com/github/streams/practice/a_easy/numbers Expand file tree Collapse file tree 3 files changed +34
-31
lines changed Original file line number Diff line number Diff line change @@ -101,4 +101,8 @@ public static long countNumberOfEvenNumbers(final List<Integer> input) {
101101 public static List <Double > convertCelsiusToFahrenheit (final List <Integer > input ) {
102102 return input .stream ().map (value -> (value * 9.0 / 5.0 ) + 32 ).toList ();
103103 }
104+
105+ public static List <String > uniqueEmailAddresses (List <String > input ) {
106+ return input .stream ().distinct ().toList ();
107+ }
104108}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ package com .github .streams .practice .a_easy .numbers .problems ;
2+
3+ import com .github .streams .practice .a_easy .numbers .EasyNumbersProblemSolution ;
4+ import java .util .List ;
5+ import org .junit .jupiter .api .Assertions ;
6+ import org .junit .jupiter .api .Test ;
7+
8+ /**
9+ * Imagine you’re building a registration system for a website. Sometimes, due to user error or
10+ * system retries, duplicate emails get stored in your list.
11+ * You want to keep only unique email addresses before sending a newsletter.
12+ */
13+ class C_UniqueEmailAddresses {
14+ @ Test
15+ void uniqueEmailAddresses () {
16+ final var input =
17+ List .of (
18+ "john.doe@example.com" ,
19+ "alice@example.com" ,
20+ "john.doe@example.com" , // duplicate
21+ "bob@example.com" ,
22+ "alice@example.com" // duplicate
23+ );
24+
25+ final var mySolution = EasyNumbersProblemSolution .uniqueEmailAddresses (input );
26+ final var yourSolution = List .of ();
27+
28+ Assertions .assertEquals (mySolution , yourSolution );
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments