MNYC '17: Hurontario

View as PDF

Submit solution

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

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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.

Input Specification

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


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

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

Output Specification

A single string described in the problem statement.

Sample Input 1


Sample Output 1


Sample Input 2


Sample Output 2


Sample Input 3


Sample Output 3



  • 0
    balathegreat999  commented on Dec. 22, 2020, 11:03 a.m. edited

    is linear time complexity too slow?

    • 0
      Kirito  commented on Dec. 22, 2020, 2: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
    aeternalis1  commented on Aug. 8, 2017, 11:07 a.m.

    Why am I TLE'ing test case 18? Is it a worst-case or is my algorithm too slow?

  • 0
    anasschoukri  commented on May 29, 2017, 6:47 p.m.

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

    • 0
      wleung_bvg  commented on May 30, 2017, 12:11 p.m.


      There is no common suffix of A and prefix of B

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

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

    • 2
      P234rex  commented on April 18, 2017, 11:36 a.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, 4:55 p.m. edit 6

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