πŸ“œ

Starts With

Starts With
쉬움 λ¬Έμžμ—΄ +10pts

Problem

Write a function that checks if a string starts with a given prefix.

Examples

Input: startsWith("hello", "he")
Output: true

Explanation

이 λ¬Έμ œλŠ” **startsWith() λ©”μ„œλ“œ**둜 λ¬Έμžμ—΄μ˜ μ‹œμž‘μ„ ν™•μΈν•˜λŠ” 방법을 ν•™μŠ΅ν•©λ‹ˆλ‹€. ## 핡심 κ°œλ…: 접두사 확인 startsWith()λŠ” λ¬Έμžμ—΄μ΄ νŠΉμ • λ¬Έμžμ—΄λ‘œ μ‹œμž‘ν•˜λŠ”μ§€ ν™•μΈν•©λ‹ˆλ‹€. ### κΈ°λ³Έ μ‚¬μš©λ²• ```javascript str.startsWith(searchString) str.startsWith(searchString, position) ``` - searchString: 찾을 접두사 - position: 검색 μ‹œμž‘ μœ„μΉ˜ (κΈ°λ³Έκ°’ 0) ### ν™œμš© μ˜ˆμ‹œ ```javascript "hello".start...

View detailed explanation β†’

Key Concepts

startsWith λ©”μ„œλ“œ 접두사 확인 λ¬Έμžμ—΄ 검사 ES6 λ©”μ„œλ“œ
Time: O(m) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.