/** Ċ Ġ* ĠCreated Ġby ĠIn no ĠF ang Ġon Ġ 2 0 1 8 / 3 / 1 . Ċ Ġ*/ Ċ Ċ /** Ċ Ġ* Ġ 1 2 4 Ġ/ Ġ 1 2 4 Ġtest Ġcases Ġpassed . Ċ Ġ* ĠStatus : ĠAccept ed Ċ Ġ* ĠRuntime : Ġ 4 4 4 Ġms Ċ Ġ*/ Ċ class ĠSolution Ġ{ ĊĠĠĠ Ġfun Ġreplace Words ( dict : ĠList < String >, Ġsentence : ĠString ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstore Ġ= Ġdict . groupBy Ġ{ Ġit [ 0 ] Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġsentence . split (" Ġ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġword Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( store . containsKey ( word [ 0 ])) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstore [ word [ 0 ]] !! ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. filter Ġ{ Ġword . startsWith ( it ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. let Ġ{ Ġif Ġ( it . isEmpty ()) Ġword Ġelse Ġit . min By Ġ{ Ġit . length Ġ} Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġword ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}. join ToString (" Ġ") ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun Ġmain ( args : ĠArray < String >) Ġ{ ĊĠĠĠ ĠSolution (). replace Words ( listOf (" c ", Ġ" b ", Ġ" r "), Ġ" the Ġc attle Ġwas Ġr att led Ġby Ġthe Ġbattery "). let (:: println ) ĊĠĠĠ ĠSolution (). replace Words ( listOf (" cat ", Ġ" bat ", Ġ" rat "), Ġ" the Ġc attle Ġwas Ġr att led Ġby Ġthe Ġbattery "). let (:: println ) ĊĠĠĠ ĠSolution (). replace Words ( listOf (" e "," k "," c "," har qp "," h "," gs afc "," vn "," l qp "," so y "," mr "," x "," i it gm "," sb "," oo "," sp j "," g wm ly "," iu "," z "," f "," ha "," v ds "," v "," v px "," fir "," t "," xo "," ap if m "," tl zn m "," k kv "," n xy ud "," j "," qp "," om n "," z ox p "," mut u "," i "," nx th "," dw uer "," sad l "," pv "," w "," md ing "," m ub em "," x sm wc "," vl "," far ov "," tw f mq "," lj h mr "," q "," bb zs "," kd "," kw c "," a "," bu q "," sm "," yi "," n yp a "," x wz "," si "," am qx "," iy "," eb "," qv gt "," tw y "," rf "," dc "," utt "," mx j fu "," hm "," tr z "," l zh "," l ref "," q bx "," f mem r "," gil "," go "," qg gh "," u ud "," tr nh f "," ge ls "," df dq "," q zk x "," qx w "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" ikk bp Ġmis zk ays Ġw qj fer q ox j wv bi ey k Ġg vc fl dk i av ww Ġv h ok ch xz Ġdv yp wy b Ġbx ah fz cf ante ib ilt ins Ġue ebf Ġl qh fl v wx ksi Ġd co Ġk dd xm ck hv q if bu zk h stp Ġwc Ġy t zz lm Ġgx im j uh z fd ju am hs u Ġg dk bm h pn vy Ġif v if he ox ql bos f ww Ġmeng fd y de kw tt k hb zen k Ġw j hm my lt me uf q vc pc xg Ġh th cu ov ils Ġld ip ov lu o Ġai pro gn Ġn us qu z pmn og t jk k lf ht a Ġk lx vv lv yh Ġn xz gn r ve gh c Ġmp pp fh z jk bu cv Ġc qc ft Ġuw ma hh q rad j tf Ġi aa as ab qq z mb c ig Ġz cp v py y ps mod toi if Ġq j ui q tf hz cp n mt k Ġy z frag c ext vx Ġiv n vg ka qs Ġi pl az v Ġj ur ts yh Ġgz ix fe ug j Ġrn uk j gt jp im Ġh sc yh gor u Ġa led y rm z wh sz Ġx b ah cw fw m Ġh zd Ġy gel dd ph x nb h Ġrv j xt lq fn lm w doe zh Ġzaw fk ko Ġi wh kc dd x gp q td rj rcv Ġb bf j Ġm hs Ġn en rq fk bf Ġsp fp az r Ġwr k ji wy f Ġcw Ġd td Ġcq ib z mu uh uk wy lr n ld Ġdt ax h dd id fw qs Ġb gn n ox gy yn ol Ġh g Ġdi jh rr pn wj lj u Ġmu zz rr s yp z gw vb lf Ġz bug ltr ny z bg Ġh k td vi ast o ire y iq f Ġq v uf x gc ix v hr jq tn a Ġip f zh uv go Ġda ee Ġr Ġn li py fs zv xl w qw Ġyo q Ġde wp gt cr za us q wh h Ġq z sa ob sg h gm Ġich l ps j ls rw zh by f hm Ġk sen b Ġb q pr arp gn y em zw if q zz Ġo ai Ġpn q ot td Ġny ges jt lp ala Ġq mx ix to ox t br zy orn Ġgy v uk j pc Ġs Ġmx hl k day cs kj Ġu vw mer pl ai be kn lt uv d Ġoc nn Ġf rot sc ys dy cl rc Ġck ct t ace u ux zc gh w Ġp xbd Ġok l wh cpp u zi ix p vi hi hp ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. let (:: println ) Ċ }