스트링 디코드 문제에서 망하고, 43분 후 복수에 성공한 이야기 (feat. 중첩 괄호도 처리함)

## 🔧 배경 얼마 전 기술 면접을 보다가 `decodeString` 문제를 받았습니다. 알고리즘 공부는 주로 BFS, DFS 쪽만 하던 터라, 문자열 파싱 문제에서 완전히 발목 잡혔습니다. 거기다 라이브 코딩. 제한 시간 30분. 당연히… 못 풀었죠. 멘탈까지 디코딩당한 날이었습니다. --- ## 🔥 복수의 시작 면접이 끝난 뒤에도 이 문제는 계속 머릿속을 맴돌았습니다. “내가 이걸 못 풀었다고? 진짜?” 그 순간부터 **마음속의 디버거**가 켜졌고, 라이브 코딩에서 시도했던 방식에서 출발해 다시 파기 시작했습니다. 스택도 쓰지 않았습니다. 재귀도 쓰지 않았습니다. 그냥 제 방식대로, 끈질기게 문자열을 조작하면서 풀었습니다. **걸린 시간: 추가 43분.** --- ## 🧠 접근 방식 요약 - `[`와 `]`를 찾는다. 가장 안쪽 괄호부터 시작. - 그 안의 문자열을 꺼내고, 반복 횟수를 계산한다. - 원래 문자열 배열을 `splice`로 조작해서 새로운 문자열을 삽입한다. - 그리고… **처음부터 다시 돌린다.** - 이걸 괄호가 다 없어질 때까지 반복한다. 사실상 **재귀를 흉내 내는 루프 기반 수동 파서**입니다. --- ## ✅ 최종 코드 (with 주석) ```javascript /** * @param {string} s * @return {string} */ var decodeString = function(s) { const strArr = s.split(''); let startIndex = -1; let endIndex = -1; for(let i = 0; i = 0 && endIndex >= 0 && endIndex > startIndex){ const addedStr = strArr.slice(startIndex + 1, endIndex).join(''); ...

블로거에서 마크다운 사용하기 - Markdown in Google Blooger

### Reference : https://github.com/cs905s/md-in-blogger?tab=readme-ov-file
참고한 문서가 작성된지 오래되어 따라하기 힘들어서 2024년 4월 기준으로 설명합니다.
I write this document because the reference I refered is too old to follow. So I had some trouble to apply markdown in Blooger using the reference.

## 1. 마크다운을 사용할 수 있도록 스크립트 코드 추가 / Add markdown script


1. 블로거 관리자페이지 왼쪽의 테마를 누르고 나오는 테마 페이지에서 버튼 오른쪽에 있는 화살표를 누릅니다. 메뉴에서 HTML 편집이 있는데 이 버튼을 누르면 테마 HTML 편집을 할 수 있는 창이 열리고 여기서 마크다운 지원을 위한 스크립트 코드를 추가해야 합니다.
In admin page, you can see theme on leftside, after clicking theme, click small arrow down icon. A menu will be released and click `Edit HTML`. You can add script code to support markdown in HTML editing page.

2. 헤드 태그를 찾아야합니다. /head 를 검색하여 `</head>` 바로 위에 하단 5줄의 스크립트 코드를 붙여넣어주세요
Find head tag. Search /head (using ctrl + f). Copy below 5 lines and paste just above of `</head>`
```
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js" type="text/javascript"/>
<script src='//cdnjs.cloudflare.com/ajax/libs/showdown/1.6.2/showdown.min.js' type='text/javascript'/>
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js' type='text/javascript'/>
<script src='//mxp22.surge.sh/markdown-highlight-in-blogger.js' type='text/javascript'/>
<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/default.min.css' rel='stylesheet'/>
```
저장합니다. 기본 셋팅은 끝났습니다.
Save it. Basic setting is done.

### 글을 작성할 때 HTML 모드를 사용하시고 글의 가장 위, 아래에 pre 태그를 아래 예시와 같이 붙입니다.
### When you write something, use HTML mode. And put pre tag like below at the top and bottom of you writing.
```
      <pre class="markdown"/>
      #Woo hoo!
      [Markdown](http://daringfireball.net/projects/markdown/) is cool!
      ```javascript
          // Verify code highlighting
          if (today==rainy) {
            return false;
          }
      ```
      </pre/>
```

Comments

Popular posts from this blog

Operating System Concepts 9th

스티키 헤더 여러개 만들기 (Multiple sticky header)

Operating System Concept