HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
💌
JJong’s Archive
/
🤖
코딩테스트
/
문장 암호화

문장 암호화

성공여부
NO
걸린시간(분)
정리
진행 중
문제출처
제로베이스
생성 일시
Apr 13, 2025 01:53 PM

1️⃣ 문제

notion image

2️⃣ 문제 해결 전략

 

3️⃣ 코드 및 설명

내 코드
 
모범 코드
function solution(sentence, keyword, skips) { const result = []; let sIdx = 0; // sentence index let kIdx = 0; // keyword index for (let i = 0; i < skips.length; i++) { const ch = keyword[kIdx]; let skip = skips[i]; let skipped = 0; while (sIdx < sentence.length && skipped < skip) { result.push(sentence[sIdx]); if (sentence[sIdx] === ch) { sIdx++; result.push(ch); break; } sIdx++; skipped++; } // 건너뛴 도중에 삽입된 경우가 아니라면 if (skipped === skip && sIdx <= sentence.length) { result.push(ch); } kIdx = (kIdx + 1) % keyword.length; } // 남은 문장 붙이기 while (sIdx < sentence.length) { result.push(sentence[sIdx]); sIdx++; } return result.join(''); }
 

4️⃣ 시간복잡도