MNYC '17: Hurontario

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 0.6s
Memory limit: 256M

Author:
Problem type

Hurontario is a cool street name. It contains both Huron and Ontario. They share two letters, on. Given two strings A and B, create the smallest string that starts with A and ends with B.

Constraints

For 40\% of the points, the length of each string is at most 1000.

For the remaining 60\% of the points, the length of each string is at most 1\,000\,000.

Input Specification

A single line will contain two space separated strings consisting of only uppercase Latin characters, A and B.

Output Specification

A single string described in the problem statement.

Sample Input 1

HURON ONTARIO

Sample Output 1

HURONTARIO

Sample Input 2

NEW YEARS

Sample Output 2

NEWYEARS

Sample Input 3

YEAR EARWIG

Sample Output 3

YEARWIG

Comments


  • 0
    maxcruickshanks  commented on July 11, 2021, 11:03 p.m. edit 3

    Since the original data were weak, 3 more test cases were added to the second batch.


    • 0
      maxcruickshanks  commented on Aug. 11, 2021, 3:40 p.m. edit 2

      An additional test case was added to both subtasks, making 1 new test case for the first batch and 4 new test cases for the second batch.


  • 0
    bariumlanthanum  commented on Dec. 22, 2020, 4:03 p.m. edited

    is linear time complexity too slow?


    • 2
      Kirito  commented on Dec. 22, 2020, 7:46 p.m.

      Linear time is intended, your solution runs in quadratic time (checking string equality is linear in the length of the string)


  • 1
    anasschoukri  commented on May 29, 2017, 10:47 p.m.

    what the output will be if the input is TROUBLE OUBE ??


    • 1
      wleung_bvg  commented on May 30, 2017, 4:11 p.m.

      TROUBLEOUBE

      There is no common suffix of A and prefix of B


  • 4
    AndrewVII  commented on April 17, 2017, 9:43 p.m. edited

    Can anyone tell me why I am getting an index error on Batch #1, Case #15?


    • 3
      P234rex  commented on April 18, 2017, 3:36 p.m.

      I think it's due to your second forloop. I can't pinpoint your exact issue but try troubleshooting with the test case BAHAHABA HAHA


  • 4
    P234rex  commented on April 17, 2017, 8:55 p.m. edit 6

    For the constraints, do they apply to the input strings or the output string?