Statistics

Problem Statement for "DeckOfCards"

Problem Statement

You found a deck of slightly non-traditional playing cards. Each card has a value and a suit. The value of each card is a positive integer, and the suit is a lowercase English letter ('a'-'z'). We will use (v, s) to denote a card with value v and suit s.


You want to know whether the deck is perfect. A perfect deck has two properties:

  • All cards in the deck are distinct. (I.e., no two cards share both value and suit.)
  • For any two cards (v1, s1) and (v2, s2) in the deck, the deck also contains the cards (v1, s2) and (v2, s1).


You are given the following data:

  • an int n: the number of cards in the deck
  • a int[] value with n elements: the values of the cards in the deck
  • a String suit with n elements: the suits of the cards in the deck

More precisely, for each valid i, (value[i], suit[i]) is one of the cards in the deck. Return "Perfect" if the deck is perfect and "Not perfect" otherwise. Note that the quotes are only for clarity and that the return value is case-sensitive.

Definition

Class:
DeckOfCards
Method:
IsValid
Parameters:
int, int[], String
Returns:
String
Method signature:
String IsValid(int n, int[] value, String suit)
(be sure your method is public)

Constraints

  • n will be between 1 and 50, inclusive.
  • value will contain exactly n elements.
  • Each element of value will be between 1 and 1,000,000,000, inclusive.
  • suit will be of length n exactly.
  • Suit will only contain lower-case alphabets ('a'-'z').

Examples

  1. 1

    {10}

    "z"

    Returns: "Perfect"

    There is only one card in the deck: (10, 'z'). The deck is obviously perfect.

  2. 3

    {1,2,3}

    "hhh"

    Returns: "Perfect"

  3. 4

    {2,3,2,3}

    "hcch"

    Returns: "Perfect"

  4. 3

    {1,1,1}

    "hch"

    Returns: "Not perfect"

    This deck is not perfect because it contains two copies of the card (1, 'h').

  5. 4

    {1,2,3,4}

    "hhcc"

    Returns: "Not perfect"

    This deck is not perfect. For example, the presence of cards (1, 'h') and (3, 'c') implies that the cards (3, 'h') and (1, 'c') should also be in the deck, but both of them are missing.

  6. 14

    {400419990,770680153,509864399,663643822,706993150,111308297,124177896,384212861,983686982,823503611,139194634,621451744,528869619,956373714}

    "pjeaoxurqfukjo"

    Returns: "Not perfect"

  7. 8

    {600430367,903656845,74158923,533577843,605697920,177204724,977338493,84173388}

    "bcoovcps"

    Returns: "Not perfect"

  8. 21

    {857738145,575063091,935687089,199300207,587803619,662733494,20311363,971363450,519867613,46371508,610565137,395730640,209826425,518163936,104422694,148547648,976225788,918707868,971545448,691725935,772290514}

    "gyfvwqblhomoigynvhvjj"

    Returns: "Not perfect"

  9. 3

    {940321263,194641390,696884903}

    "lsm"

    Returns: "Not perfect"

  10. 37

    {222473686,955543254,93250883,100957242,382631286,939773582,737207348,776552323,54038165,834402345,920708435,163819934,375638701,894382564,502516064,930788091,264013929,582559461,783006987,391386150,750184106,872306767,557193505,487622014,85766751,269652255,434104144,705112202,978105561,3458314,277152613,203838862,121823643,885246295,19399874,133537590,502935193}

    "afqbfushdwwdsplquxocijnfdmcfbspgpqfys"

    Returns: "Not perfect"

  11. 15

    {705919988,802165937,189835178,632104221,93284051,916347860,472641666,733515117,993333000,548860141,58824369,163876292,126893796,879877421,425748118}

    "qmyhghgqxxzzccx"

    Returns: "Not perfect"

  12. 23

    {675913887,158980216,110528165,87523555,818392973,99422346,66167705,232307670,197828407,55417325,95443621,740198571,777474041,510750020,11132127,111759838,944303851,948288382,648046902,84290565,366298847,312245239,71798854}

    "lvnbprmryejzvuvacxauplv"

    Returns: "Not perfect"

  13. 12

    {813260637,830025794,960647326,986372762,572536213,58034327,353802074,263897904,979767586,54270399,246035727,434303010}

    "bdzkwqvczyby"

    Returns: "Not perfect"

  14. 3

    {98177403,654386513,814329051}

    "uxf"

    Returns: "Not perfect"

  15. 37

    {425256143,672111315,351963542,789590139,934893347,895377261,24897137,738102671,362289207,79945619,106925321,191770841,266195697,139738234,188665892,428842,710696434,107162890,452609747,51639524,366203672,78198457,15307548,344907445,639677343,486015085,637247278,680399215,425733358,562020530,592087483,652567600,566638510,630861634,780706097,431413678,819542174}

    "cqvdkthatmwajuzczimdduxpgiqjhprgsgapb"

    Returns: "Not perfect"

  16. 14

    {883592027,855737859,461402152,831160354,914641780,187538440,290741499,527971196,723209259,347850381,266929178,453034607,362317069,570319838}

    "ptafnfznsoahlw"

    Returns: "Not perfect"

  17. 28

    {828149280,884801644,141002511,618549765,745984688,846446003,62002818,873651123,422357387,773887583,734615299,241716230,567221940,520416819,326900064,495814671,44525676,728899300,530577369,221293266,615435528,235085272,229169868,197028489,408488600,12894474,597779936,265795430}

    "qpjktmalrujvwyzstampxiemoulj"

    Returns: "Not perfect"

  18. 32

    {67050304,798048520,350803957,953724573,500377889,645907077,571716453,162086450,284769995,301297802,678475688,379879487,750336986,792232717,337784552,519285696,885175143,947382463,239328368,382815120,45146494,785935315,83770127,800682464,403818288,609331956,300626277,172361284,151407398,235996136,306176993,968889105}

    "qrbqerqnyrtdlgmbymijcfavzvlahrgu"

    Returns: "Not perfect"

  19. 34

    {286722932,637441684,111835225,3125751,518163113,395563126,453127084,834836734,686093199,556907196,663185740,814577881,300407637,266123997,730143438,875602534,345484342,421777912,74998589,122160821,437489037,284167985,164202301,751663572,196435719,2579107,929786292,659587920,42716287,138434061,120427371,893433528,295695698,33305975}

    "lllmzdhcrlvrrqdibprgfydnpowxrdwlrh"

    Returns: "Not perfect"

  20. 17

    {299991798,249062339,415434804,224008323,432808506,938988315,966753272,194727855,440288710,989150048,3422845,13795570,665594060,999134666,913973525,957520056,602560570}

    "lpixkojeuqnlqatlo"

    Returns: "Not perfect"

  21. 14

    {892507654,545403908,534564727,762147672,53626551,659465652,498429773,618306426,465388617,684651266,102050075,29649100,938958180,360264882}

    "sjiydcigavkjiq"

    Returns: "Not perfect"

  22. 15

    {38437847,831063056,133578884,744733378,666014131,143095196,261391745,121307944,702417170,948220446,323400430,247413903,912573380,700797071,434901083}

    "lrkfgdybyqmujbm"

    Returns: "Not perfect"

  23. 21

    {821652569,895226866,521365219,575535578,17447466,517839467,84945356,850550696,266143677,7881675,231910505,596282379,545533032,551425144,367408387,251675637,357490697,238598324,729271927,524228787,129052297}

    "gxcvumizuqxjushcqwdca"

    Returns: "Not perfect"

  24. 22

    {191459447,98689711,356247169,97336125,289682475,79384967,802727601,276249154,206978404,3285305,642189634,78292794,758296838,799817442,538231575,616571797,902943339,71867820,199929998,264545451,72678434,77862}

    "eykwlvadxkzpmjgdmrlyoh"

    Returns: "Not perfect"

  25. 27

    {818244216,433880538,333609872,146900192,741128602,943857498,333354149,943681468,891671800,715679324,359099303,951708030,506631243,97887915,104192442,109625917,410842599,630108145,494480964,633698948,797515825,377183192,743944950,504458635,988748183,73063880,79070205}

    "qixpjcjojeabnarihvzwgpvgmay"

    Returns: "Not perfect"

  26. 4

    {81871591,315028663,861529908,828859358}

    "nldv"

    Returns: "Not perfect"

  27. 12

    {74500035,786957488,742708819,331024758,765382686,4974551,960298488,12641178,607259978,742205240,44385867,678527353}

    "nycnnxgwcztc"

    Returns: "Not perfect"

  28. 24

    {333879297,527859501,172566764,670113638,321889159,29533071,513712473,969813199,98028249,437661988,555472181,161982431,203139001,908642427,155148934,29916609,263219449,277780029,16762183,47756063,952221881,128620765,730537207,808946003}

    "vtxthbyofalhqjhoykpaaebz"

    Returns: "Not perfect"

  29. 10

    {29920259,505727739,434506651,448471030,738983497,155656167,996411950,134700985,680192302,994404584}

    "ucwdzkjqch"

    Returns: "Not perfect"

  30. 39

    {127355661,76787098,394379447,34289455,9608421,289957019,34685959,33539313,127753364,711267470,704273743,887248253,292721965,779511848,706394260,828694406,172479883,381123185,360304117,332910967,557081015,854939499,209353053,168805574,807807625,535395025,515003958,834852087,759107803,817046296,976823542,124538781,30619464,553670064,269750707,774090042,754049333,913278126,121068278}

    "xgqqpxygaswphulilcgvhheyownpthdnbsjtfsm"

    Returns: "Not perfect"

  31. 7

    {385590290,906343755,807537467,565955475,509978470,745685749,182468879}

    "jfspaig"

    Returns: "Not perfect"

  32. 39

    {755390710,98264861,722838467,5238304,697035450,777399819,208217239,178166982,290391840,730257576,408649674,240192100,927550613,918390504,201465827,604822096,280793536,421563260,706070450,596739551,83509351,711761470,682450519,406339926,240359905,280168827,457513486,12322066,376789587,584454919,700684918,359613366,328908224,641422272,703183378,456959696,182996907,849220583,4149660}

    "yjvtoalzcihanrvckgtohzpfruulwgkrbbojgsr"

    Returns: "Not perfect"

  33. 40

    {914172020,776599977,247123804,953799602,819722867,776362595,191890425,176051967,442158093,926172350,487093588,113174353,11367808,20378760,58258837,917481179,754723055,702187764,442849413,289871085,506853270,970087003,487522257,790215356,47554583,758113319,332351144,509110710,249533030,817825152,274654347,687010344,39460868,965775247,508096722,118066748,85837699,6224503,98878548,95981913}

    "lnjrfqozizxtgcpgdgladahnipczobrjaofvpzvt"

    Returns: "Not perfect"

  34. 37

    {582026622,95103176,919249073,467887046,307752301,799531469,136198497,426486730,10896235,115511165,346966300,139627639,738046457,100175003,716150357,731260694,550668864,511814580,419670993,383743855,650758048,562453590,64951715,708682999,418231349,962190431,7300271,406559692,386147810,793913490,994822198,835597037,920764470,709919259,216303184,558660394,898532914}

    "qpazaluczgmrgeskkkanyqygnknjrcklzmjpn"

    Returns: "Not perfect"

  35. 1

    {494365253}

    "d"

    Returns: "Perfect"

  36. 48

    {79790729,805948347,79790729,79790729,805948347,79790729,79790729,805948347,79790729,79790729,805948347,805948347,805948347,805948347,79790729,805948347,79790729,79790729,805948347,805948347,79790729,805948347,805948347,79790729,79790729,79790729,79790729,805948347,79790729,805948347,805948347,79790729,79790729,805948347,805948347,805948347,805948347,79790729,79790729,805948347,805948347,805948347,79790729,79790729,79790729,805948347,79790729,805948347}

    "bznjqpsroqaiecdpmtbxlvorzxfnihmewfwktcvsdjkahlgg"

    Returns: "Perfect"

  37. 22

    {404207159,168578728,24813729,564712875,290625716,563642450,176994491,940400461,978372948,127636737,381252005,44532157,834227422,105858138,18929046,552873023,647437178,225477557,481542336,732512063,122623833,85625316}

    "ssssssssssssssssssssss"

    Returns: "Perfect"

  38. 16

    {23201235,130792662,41578310,41578310,1977478,1977478,130792662,23201235,41578310,1977478,1977478,23201235,41578310,23201235,130792662,130792662}

    "oomivmiiviovommv"

    Returns: "Perfect"

  39. 50

    {983101984,295582165,451609073,983101984,48826842,512733416,258994873,740158196,657208219,451609073,983101984,258994873,451609073,86942112,451609073,48826842,740158196,512733416,124944883,86942112,295582165,740158196,258994873,512733416,657208219,657208219,48826842,48826842,124944883,295582165,295582165,124944883,512733416,258994873,295582165,48826842,124944883,86942112,451609073,512733416,124944883,740158196,86942112,983101984,740158196,657208219,983101984,657208219,86942112,258994873}

    "aakqyyzyqazqzaqkzqaykakzkyzqqzyyayqakzykzqqykzkaka"

    Returns: "Perfect"

  40. 13

    {598351514,598351514,598351514,598351514,598351514,598351514,598351514,598351514,598351514,598351514,598351514,598351514,598351514}

    "lipjntsomqfkz"

    Returns: "Perfect"

  41. 25

    {309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275,309249275}

    "qckeowdjmhlgantivsfpxzbuy"

    Returns: "Perfect"

  42. 18

    {5773741,864023491,5773741,864023491,283639570,151353995,151353995,978917689,864023491,195462644,283639570,151353995,283639570,5773741,978917689,195462644,978917689,195462644}

    "pttlplttpttpllpllp"

    Returns: "Perfect"

  43. 24

    {768265144,768265144,768265144,177593624,768265144,177593624,768265144,961236079,961236079,961236079,177593624,177593624,961236079,177593624,961236079,177593624,961236079,768265144,768265144,768265144,961236079,177593624,961236079,177593624}

    "hzwwlnszlhsmwhslmnmgnzgg"

    Returns: "Perfect"

  44. 20

    {617739526,617739526,954803660,954803660,954803660,57742009,57742009,617739526,197330846,617739526,57742009,954803660,197330846,197330846,57742009,954803660,197330846,617739526,57742009,197330846}

    "mdomcdhochmdhmchocod"

    Returns: "Perfect"

  45. 48

    {160792823,655732183,403943565,160792823,185529180,101013230,42656010,229749352,42656010,438386978,807488813,290711077,403943565,792229999,48626974,438386978,792229999,973458184,248735986,148017765,910531429,4706471,4706471,290711077,101013230,158824943,655732183,14723530,229749352,948496323,676650560,676650560,26753767,26753767,910531429,14723530,248735986,807488813,826462940,948496323,158824943,148017765,333241875,826462940,185529180,333241875,48626974,973458184}

    "ziiiziziiizzziizzzzziziizzzizzizzizziiiiiiizizzi"

    Returns: "Perfect"

  46. 16

    {557077168,799381978,914728497,914728497,799381978,914728497,305538793,305538793,914728497,557077168,557077168,799381978,557077168,305538793,799381978,305538793}

    "hjbuhhjujubujbbh"

    Returns: "Perfect"

  47. 34

    {257898855,257898855,561322876,648892022,873959908,665412325,665412325,439672681,399623043,283102726,377300385,760544379,884039533,3495117,561322876,283102726,6237482,648892022,245406433,6237482,76715902,377300385,3495117,245406433,873959908,399623043,760544379,198829653,884039533,76715902,198829653,637579540,439672681,637579540}

    "tbbttbtbtbttbtttbbbttbbtbbbbtbtbtt"

    Returns: "Perfect"

  48. 12

    {395409915,340020781,395409915,340020781,340020781,340020781,340020781,395409915,340020781,395409915,395409915,395409915}

    "bxdpbdfxnfpn"

    Returns: "Perfect"

  49. 24

    {881361111,37632177,724175698,916768393,431111931,431111931,724175698,916768393,431111931,881361111,431111931,841462412,916768393,841462412,841462412,37632177,37632177,724175698,724175698,841462412,916768393,881361111,37632177,881361111}

    "tzqtpqzztzzppqzpttptqqqp"

    Returns: "Perfect"

  50. 8

    {107653892,596188773,107653892,596188773,107653892,107653892,596188773,596188773}

    "vcnoocnv"

    Returns: "Perfect"

  51. 38

    {7680986,684315239,69758519,977461097,461699971,725957758,186818349,461699971,684315239,234882923,23682563,725957758,38274654,602326869,954736129,23682563,518273779,45271491,347602976,69758519,7680986,731719501,518273779,954736129,38274654,110401871,731719501,602326869,52824412,234882923,45271491,347602976,52824412,977461097,156770313,110401871,156770313,186818349}

    "kkkykkyyyykyyyyyykyyykkkkyykykykkkykkk"

    Returns: "Perfect"

  52. 45

    {921770904,188029846,861002774,861002774,967529643,269160179,153949624,117690277,461270300,188029846,461270300,967529643,967529643,269160179,188029846,188029846,921770904,921770904,117690277,269160179,269160179,269160179,153949624,317496589,921770904,317496589,317496589,153949624,921770904,967529643,861002774,317496589,461270300,153949624,461270300,461270300,861002774,861002774,117690277,153949624,117690277,967529643,188029846,117690277,317496589}

    "xkwakkwaxxwrwxraawxrwakxrwaakaxrkrarkrkxwxwrk"

    Returns: "Perfect"

  53. 15

    {125773237,125773237,551732027,551732027,746868805,551732027,551732027,746868805,746868805,746868805,746868805,551732027,125773237,125773237,125773237}

    "nzhzeenzfhnfhef"

    Returns: "Perfect"

  54. 34

    {151639014,299373030,8313483,249146534,326781081,138254920,73117580,756179426,8313483,62478891,605647060,494275710,151639014,970849946,9822101,249146534,37633834,516772460,73117580,299373030,825094568,605647060,138254920,62478891,494275710,756179426,970849946,37633834,93926182,516772460,825094568,9822101,326781081,93926182}

    "jfjfjffffffffjjjffjjfjjjjjfjjjjfff"

    Returns: "Perfect"

  55. 20

    {644184634,676405831,644184634,676405831,519516852,644184634,346062305,519516852,367336171,676405831,346062305,519516852,367336171,519516852,346062305,367336171,676405831,346062305,367336171,644184634}

    "neuullueuneunnlllnee"

    Returns: "Perfect"

  56. 24

    {364774938,130025342,364774938,499532553,364774938,499532553,75978466,130025342,75978466,499532553,130025342,499532553,364774938,130025342,75978466,75978466,130025342,364774938,130025342,499532553,364774938,75978466,75978466,499532553}

    "kfhezzeehhhqqqkqkfzkefzf"

    Returns: "Perfect"

  57. 34

    {248616866,315828703,457113014,237975590,700902778,829920366,418100286,615537872,315828703,260195552,149404173,260195552,237975590,565287291,457113014,3749775,293451572,149404173,565287291,293451572,829920366,615537872,709248877,3749775,418100286,709248877,248616866,420514040,420514040,700902778,538404434,834152188,834152188,538404434}

    "sgssggggsssgggggsgsgssgsssgsgsggss"

    Returns: "Perfect"

  58. 36

    {925622089,265456921,492015619,492015619,882678701,510166986,111019129,789389243,578160389,210919622,351872727,510166986,156856003,561993365,109369324,789389243,547920623,267293003,547920623,156856003,925622089,882678701,351872727,561993365,5178738,494450777,373595003,267293003,109369324,373595003,111019129,578160389,5178738,265456921,494450777,210919622}

    "ddwdwddddwwwdwdwdwwwwddddwddwwwwwwdd"

    Returns: "Perfect"

  59. 12

    {634479762,11745702,11745702,11745702,11745702,11745702,634479762,11745702,634479762,634479762,634479762,634479762}

    "ppyfcbaacfyb"

    Returns: "Perfect"

  60. 27

    {164802589,938563230,164802589,376170465,164802589,938563230,164802589,164802589,938563230,376170465,938563230,376170465,164802589,376170465,376170465,376170465,938563230,164802589,938563230,938563230,938563230,376170465,376170465,938563230,164802589,376170465,164802589}

    "nhhoaaielcnnwelhwcieowacoil"

    Returns: "Perfect"

  61. 34

    {63360478,333605184,63360478,63360478,63360478,63360478,333605184,63360478,333605184,333605184,63360478,63360478,333605184,333605184,63360478,63360478,333605184,333605184,63360478,63360478,333605184,63360478,333605184,333605184,63360478,333605184,333605184,63360478,333605184,333605184,63360478,333605184,333605184,63360478}

    "qskdvozeedrmqklafosfyilrcamtctzivy"

    Returns: "Perfect"

  62. 48

    {755717250,914494164,184659017,603223424,411301004,755717250,755717250,779076307,184659017,128145199,105772875,603223424,286295870,105772875,286295870,450211998,603223424,411301004,914494164,450211998,779076307,779076307,411301004,286295870,914494164,52020715,411301004,755717250,727679184,105772875,727679184,52020715,603223424,184659017,128145199,105772875,727679184,914494164,128145199,450211998,450211998,52020715,727679184,184659017,286295870,128145199,779076307,52020715}

    "ohsoohcchscccssohsshsohoohcschscsohoocoscohchchs"

    Returns: "Perfect"

  63. 44

    {130969725,430902401,409262586,86144755,37413094,130969725,409262586,130969725,689238739,736629128,291887245,301656227,86144755,301656227,861779117,37413094,130969725,291887245,409262586,37413094,301656227,75491113,736629128,430902401,689238739,301656227,75491113,861779117,736629128,689238739,861779117,291887245,736629128,430902401,75491113,291887245,861779117,430902401,409262586,86144755,689238739,86144755,75491113,37413094}

    "dludkkduluuludklllkuuukkdkluludddddklulkklkd"

    Returns: "Perfect"

  64. 28

    {737819069,737819069,954498099,737819069,737819069,737819069,954498099,954498099,737819069,737819069,954498099,737819069,954498099,737819069,954498099,954498099,954498099,954498099,954498099,737819069,954498099,737819069,954498099,737819069,954498099,737819069,737819069,954498099}

    "mfsrclmgjsleayeufyiirgcvvuaj"

    Returns: "Perfect"

  65. 24

    {682275984,682275984,518323537,682275984,597254949,597254949,682275984,682275984,682275984,597254949,518323537,518323537,518323537,597254949,518323537,597254949,682275984,597254949,682275984,518323537,597254949,597254949,518323537,518323537}

    "mrwwfridkigrfkkggdfiwmmd"

    Returns: "Perfect"

  66. 4

    {1, 2, 3, 4 }

    "hhcc"

    Returns: "Not perfect"

  67. 3

    {1, 2, 3 }

    "hhh"

    Returns: "Perfect"

  68. 3

    {100000, 100000, 100000 }

    "hhh"

    Returns: "Not perfect"

  69. 2

    {1, 1 }

    "aa"

    Returns: "Not perfect"

  70. 5

    {1, 2, 3, 4, 2 }

    "hhccz"

    Returns: "Not perfect"

  71. 2

    {1, 1 }

    "ab"

    Returns: "Perfect"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: