๐Ÿ“œ

Camel to Kebab Case

Camel to Kebab Case
๋ณดํ†ต ๋ฌธ์ž์—ด +20pts

Problem

Write a function that converts camelCase to kebab-case.

Examples

Input: camelToKebab("helloWorld")
Output: "hello-world"

Explanation

์ด ๋ฌธ์ œ๋Š” **์ •๊ทœํ‘œํ˜„์‹**๊ณผ **์ผ€์ด์Šค ๋ณ€ํ™˜**์„ ํ•™์Šตํ•ฉ๋‹ˆ๋‹ค. ์›น ๊ฐœ๋ฐœ์—์„œ CSS ์†์„ฑ๊ณผ JavaScript ์†์„ฑ ๊ฐ„ ๋ณ€ํ™˜์— ์ž์ฃผ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. **์ผ€์ด์Šค ์Šคํƒ€์ผ** - camelCase: backgroundColor (JavaScript) - kebab-case: background-color (CSS) - snake_case: background_color (Python) **์ •๊ทœํ‘œํ˜„์‹ ๋ถ„์„: /([A-Z])/g** - `[A-Z]`: ๋Œ€๋ฌธ์ž A-Z ์ค‘ ํ•˜๋‚˜ - `()`: ์บก์ฒ˜ ๊ทธ๋ฃน (๋งค์น˜๋œ ๋ฌธ์ž๋ฅผ ์ €์žฅ) - `g`: ์ „์—ญ ...

View detailed explanation โ†’

Key Concepts

์ •๊ทœํ‘œํ˜„์‹ ์บก์ฒ˜ ๊ทธ๋ฃน replace ๋ฉ”์„œ๋“œ ์ผ€์ด์Šค ๋ณ€ํ™˜ $1 ์ฐธ์กฐ
Time: O(n) Space: O(n)
solution.js
Ctrl + Enter
Run tests to see results here.