package Ġkat as . kotlin . leetcode . unique _ email _ addresses Ċ Ċ import Ġdat sok . should Equal Ċ import Ġorg . junit . Test Ċ Ċ /** Ċ Ġ* Ġhttps :// leetcode . com / problems / unique - email - addresses / Ċ Ġ*/ Ċ class ĠUnique Email Addresses Tests Ġ{ ĊĠĠĠ Ġ@ Test Ġfun Ġ` check Ġhow Ġmany Ġdifferent Ġaddresses Ġreceive Ġm ails `() Ġ{ ĊĠĠĠĠĠĠĠ Ġnum Unique Emails ( array Of (" foo @ gmail . com ")) Ġshould Equal Ġ 1 ĊĠĠĠĠĠĠĠ Ġnum Unique Emails ( array Of (" foo @ gmail . com ", Ġ" bar @ gmail . com ")) Ġshould Equal Ġ 2 ĊĠĠĠĠĠĠĠ Ġnum Unique Emails ( array Of (" foo @ gmail . com ", Ġ" f . o . o @ gmail . com ", Ġ" bar @ gmail . com ")) Ġshould Equal Ġ 2 ĊĠĠĠĠĠĠĠ Ġnum Unique Emails ( array Of (" foo @ gmail . com ", Ġ" foo + name @ gmail . com ", Ġ" bar @ gmail . com ")) Ġshould Equal Ġ 2 ĊĊĠĠĠĠĠĠĠ Ġnum Unique Emails ( array Of (" test . email + alex @ leetcode . com "," test . e . mail + bob . c athy @ leetcode . com "," test email + david @ lee . t code . com ")) Ġshould Equal Ġ 2 ĊĠĠĠ Ġ} Ċ } Ċ Ċ private Ġfun Ġnum Unique Emails ( emails : ĠArray < String >): ĠInt Ġ{ ĊĠĠĠ Ġreturn Ġemails ĊĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġemail Ġ-> Ġemail . split ("@ "). let Ġ{ Ġit [ 0 ] Ġto Ġit [ 1 ] Ġ} Ġ} ĊĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġ( local Name , Ġdomain Name ) Ġ-> Ġlocal Name . replace (".", Ġ"") Ġto Ġdomain Name Ġ} ĊĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġ( local Name , Ġdomain Name ) Ġ-> Ġlocal Name . take While Ġ{ Ġit Ġ!= Ġ'+' Ġ} Ġto Ġdomain Name Ġ} ĊĠĠĠĠĠĠĠ Ġ. distinct () ĊĠĠĠĠĠĠĠ Ġ. size Ċ }