We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Data Structures
  3. Trie
  4. No Prefix Set
  5. Discussions

No Prefix Set

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 145 Discussions, By:

votes

Please Login in order to post a comment

  • TusharDwivedi
    6 years ago+ 9 comments

    Just remember that there will be two conditions to check. (Look out for abc and abcde in below test cases):

    1. The prefix string comes before the longer string.

      • 7
      • aab
      • defgab
      • abc
      • abcde
      • cedaaa
      • bbbbbbbbbb
      • jabjjjad
    2. Prefix string will come after the longer string.

      • 7
      • aab
      • defgab
      • abcde
      • abc
      • cedaaa
      • bbbbbbbbbb
      • jabjjjad

    Make sure that you get correct output for both the cases, and you may trust that other things will fall in place.

    59|
    Permalink
    View more Comments..
  • devbabu
    7 years ago+ 1 comment

    @bokamvinaykumar Please upload the test cases.

    32|
    Permalink
  • squire40
    5 years ago+ 1 comment

    These instructions are not clear. They say "Output GOOD SET if the set is valid. Else, output BAD SET followed by the first string for which the condition fails."

    Is the first string for which the condition fails the string that is a prefix of another string, the string that is prefixed by another string, or the first string that appears ordinally in the input list?

    15|
    Permalink
  • as_mallem
    5 years ago+ 3 comments

    I believe that the test cases here are not all correct : let me give you an example I got this test case

    100
    hgiiccfchbeadgebc
    biiga
    edchgb
    ccfdbeajaeid
    ijgbeecjbj
    bcfbbacfbfcfbhcbfjafibfhffac
    ebechbfhfcijcjbcehbgbdgbh
    ijbfifdbfifaidje
    acgffegiihcddcdfjhhgadfjb
    ggbdfdhaffhghbdh
    dcjaichjejgheiaie
    d
    jeedfch
    ahabicdffbedcbdeceed
    fehgdfhdiffhegafaaaiijceijdgbb
    beieebbjdgdhfjhj
    ehg
    fdhiibhcbecddgijdb
    jgcgafgjjbg
    c
    fiedahb
    bhfhjgcdbjdcjjhaebejaecdheh
    gbfbbhdaecdjaebadcggbhbchfjg
    jdjejjg
    dbeedfdjaghbhgdhcedcj
    decjacchhaciafafdgha
    a
    hcfibighgfggefghjh
    ccgcgjgaghj
    bfhjgehecgjchcgj
    bjbhcjcbbhf
    daheaggjgfdcjehidfaedjfccdafg
    efejicdecgfieef
    ciidfbibegfca
    jfhcdhbagchjdadcfahdii
    i
    abjfjgaghbc
    bddeejeeedjdcfcjcieceieaei
    cijdgbddbceheaeececeeiebafgi
    haejgebjfcfgjfifhihdbddbacefd
    bhhjbhchdiffb
    jbbdhcbgdefifhafhf
    ajhdeahcjjfie
    idjajdjaebfhhaacecb
    bhiehhcggjai
    bjjfjhiice
    aif
    gbbfjedbhhhjfegeeieig
    fefdhdaiadefifjhedaieaefc
    hgaejbhdebaacbgbgfbbcad
    heghcb
    eggadagajjgjgaihjdigihfhfbijbh
    jadeehcciedcbjhdeca
    ghgbhhjjgghgie
    ibhihfaeeihdffjgddcj
    hiedaegjcdai
    bjcdcafgfjdejgiafdhfed
    fgdgjaihdjaeefejbbijdbfabeie
    aeefgiehgjbfgidcedjhfdaaeigj
    bhbiaeihhdafgaciecb
    igicjdajjdegbceibgebedghihihh
    baeeeehcbffd
    ajfbfhhecgaghgfdadbfbb
    ahgaccehbgajcdfjihicihhc
    bbjhih
    a
    cdfcdejacaicgibghgddd
    afeffehfcfiefhcagg
    ajhebffeh
    e
    hhahehjfgcj
    ageaccdcbbcfidjfc
    gfcjahbbhcbggadcaebae
    gi
    edheggceegiedghhdfgabgcd
    hejdjjbfacggdccgahiai
    ffgeiadgjfgecdbaebagij
    dgaiahge
    hdbaifh
    gbhccajcdebcig
    ejdcbbeiiebjcagfhjfdahbif
    g
    ededbjaaigdhb
    ahhhcibdjhidbgefggdjebfcf
    bdigjaehfchebiedajcjdh
    fjehjgbdbaiifi
    fbgigbdcbcgffdicfcidfdafghajc
    ccajeeijhhb
    gaaagfacgiddfahejhbgdfcfbfeedh
    gdajaigfbjcdegeidgaccjfi
    fghechfchjbaebcghfcfbdicgaic
    cfhigaciaehacdjhfcgajgbhhgj
    edhjdbdjccbfihiaddij
    cbbhagjbcadegicgifgghai
    hgdcdhieji
    fbifgbhdhagch
    cbgcdjea
    dggjafcajhbbbaja
    bejihed
    eeahhcggaaidifdigcfjbficcfhjj
    

    the output is supposed to be (as suggested by the test case):

    BAD SET
    d
    

    How come?????

    is there any word which is a prefix of "d"?

    if you think so, give me which one???

    8|
    Permalink
  • gauravgupta5895
    6 years ago+ 1 comment

    how to optimize the code for this as my code is not running for last 5 cases . help me !!!

    8|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature