Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    Practice problems / Minimum window substring

    Minimum window substring

    Hardsliding windowhash mapstring

    Return the shortest contiguous part of s that contains every character of t (with repeats). If several tie, return the leftmost. If none exists, return an empty string.

    Example 1

    Input:  s = "ADOBECODEBANC", t = "ABC"
    Output: "BANC"

    Example 2

    Input:  s = "a", t = "a"
    Output: "a"

    Example 3

    Input:  s = "a", t = "aa"
    Output: ""

    Constraints

    • 1 ≤ s.length, t.length ≤ 10⁵
    • English letters

    Submit checks your solution against 8 tests, including hidden ones.

    /**
     * @param {string} s
     * @param {string} t
     * @return {string}
     */
    function minWindow(s, t) {
      
    }
    
    Sign in to run
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.