Posts

스트링 디코드 문제에서 망하고, 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(''); ...

apache httpd, tomcat 연동

아파치, 톰캣, mod_jk 설치 1. 압축해제 tar -zxvf tomcat-connectors.tar 2. mod_jk 소스의(방금 압축 푼 커넥터) native 디렉터리로 이동한 뒤 configure 명령 실행 ./configure --with-apxs=아파치/bin/apxs tip : find / -name apxs 3. configure 을 통해 설정이 끝나면 make 으로 컴파일 make 4. make 후 make install 으로 코드 설치 make install 5. 설치가 되면 아파치 디렉터리에 모듈 생성됨. 6. connectors 소스의 apache-2.0 디렉터리에 있는 mod_jk.so를 apache httpd 서버의 modules 디렉토리로 복사 7. mod_jk.so 의 권한 설정 chmod 755 mod_jk.so chown root:root mod_jk.so 8. httpd 서ㅓ 설정 편집을 위해 apache 서버의 conf 디렉토리에서 vim mod_jk.conf LoadModule jk_module modules/mod_jk.so JkWorkersFile conf/workers.properties JkLogFile logs/mod_jk.log JkLogLevel info JkMount /* node1 //위의 텍스트 설명 LoadModule : 모듈 경로 - 아파치를 시작할 때 모듈을 로드할 위치 정의 JkWorkersFile : 작업자 파일 경로 - 작업자 파일 위치 정의. 작업자 파일은 톰캣 인스턴스 IP, port, road ballancing 정보 포함. JkLogFile : 로그 파일 경로 JkMount : URL 매핑 - 정의된 URL 요청 재전송 규칙 정의. 위의 경우는 /*의 경로를 입력했을 때 해당 요청을 톰캣 node1로 재전송. JkLogLevel : 로그 수준 : mod_jk에서 수행하는 다양한 이벤트를 logs가 어떻게 처리할...

Operating System Concept

6.1 A CPU -scheduling algorithm determines an order for the execution of its scheduled processes. Given n processes to be scheduled on one processor, how many different schedules are possible? Give a formula in terms of n. 처리상태->준비상태 (타이머 인터럽트 등) 처리상태->블록상태 (i/o요청이나 wait() 등) 블록상태->준비상태 (i/o의 완료 등) 프로세스 종료 6.2 Explain the difference between preemptive and nonpreemptive scheduling. 선점형 스케줄링의 경우 프로세스가 끝나지 않더라도 강제적으로 cpu 점유를 뺏어 다른 프로세스에게 할당해주지만 비선점형 스케줄링의 경우 cpu 를 사용하고 있는 프로세스가 끝날 때까지 그 프로세스에게 cpu를 사용하게 해준 후 끝나면 다음 프로세스에게 cpu를 할당해준다. 6.3 Suppose that the following processes arrive for execution at the times indicated. Each process will run for the amount of time listed. In answering the questions, use nonpreemptive scheduling, and base all decisions on the information you have at the time the decision must be made. Process Arrival Time Burst Time P 1 0.0 8 P 2 0.4 4 P 3 1.0 1 a. What is the average turnaround time for these processes wi...

Popular posts from this blog

Operating System Concept

Operating System Concepts 9th

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