<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>jh_y.log</title>
        <link>https://velog.io/</link>
        <description>안녕하세요.</description>
        <lastBuildDate>Sun, 30 Mar 2025 03:00:40 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>jh_y.log</title>
            <url>https://velog.velcdn.com/images/jh_y/profile/d313d16d-d0dc-4f83-89d8-e042314f5eb5/image.png</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. jh_y.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/jh_y" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[복잡도(Big-O 표기법)]]></title>
            <link>https://velog.io/@jh_y/%EB%B3%B5%EC%9E%A1%EB%8F%84Big-O-%ED%91%9C%EA%B8%B0%EB%B2%95</link>
            <guid>https://velog.io/@jh_y/%EB%B3%B5%EC%9E%A1%EB%8F%84Big-O-%ED%91%9C%EA%B8%B0%EB%B2%95</guid>
            <pubDate>Sun, 30 Mar 2025 03:00:40 GMT</pubDate>
            <description><![CDATA[<h2 id="복잡도란">복잡도란?</h2>
<ul>
<li>알고리즘이 문제를 해결하는 데 걸리는 <strong>시간</strong>과 사용하는 <strong>메모리 양</strong>을 수치적으로 나타낸 것</li>
<li>입력 크기 <code>N</code>이 커질수록 <strong>성능이 어떻게 변하는지</strong>를 분석</li>
<li>주로 두 가지를 평가:<ul>
<li>시간 복잡도 (Time Complexity)</li>
<li>공간 복잡도 (Space Complexity)</li>
</ul>
</li>
</ul>
<hr>
<h2 id="시간-복잡도-time-complexity">시간 복잡도 (Time Complexity)</h2>
<h3 id="정의">정의</h3>
<ul>
<li>입력 크기 <code>N</code>에 따라 <strong>알고리즘이 수행하는 연산 횟수</strong>를 수학적으로 표현</li>
<li>반복문, 재귀 호출 등을 기준으로 분석</li>
<li>일반적으로 <strong>최악의 경우(Worst-case)</strong> 기준으로 분석</li>
</ul>
<h3 id="big-o-표기법이란">Big-O 표기법이란?</h3>
<ul>
<li>가장 영향력이 큰 항만 남기고, 나머지는 생략하는 방식</li>
<li>입력이 커질수록 전체 실행 시간에 가장 영향을 주는 항을 남겨 단순화</li>
</ul>
<p>ex)  <code>O(3N² + 2N + 5) → O(N²)</code></p>
<hr>
<h2 id="주요-시간-복잡도-정리">주요 시간 복잡도 정리</h2>
<table>
<thead>
<tr>
<th>표기</th>
<th>의미</th>
<th>예시</th>
</tr>
</thead>
<tbody><tr>
<td>O(1)</td>
<td>상수 시간</td>
<td>변수 출력, 인덱스 접근 등</td>
</tr>
<tr>
<td>O(log N)</td>
<td>로그 시간</td>
<td>이진 탐색</td>
</tr>
<tr>
<td>O(N)</td>
<td>선형 시간</td>
<td>리스트 전체 탐색</td>
</tr>
<tr>
<td>O(N log N)</td>
<td>선형로그</td>
<td>병합 정렬, 퀵 정렬</td>
</tr>
<tr>
<td>O(N²)</td>
<td>이차 시간</td>
<td>이중 반복문</td>
</tr>
<tr>
<td>O(2^N)</td>
<td>지수 시간</td>
<td>완전탐색(재귀)</td>
</tr>
<tr>
<td>O(N!)</td>
<td>팩토리얼</td>
<td>순열 생성</td>
</tr>
</tbody></table>
<hr>
<h2 id="시간-복잡도-예시-코드">시간 복잡도 예시 코드</h2>
<pre><code class="language-python"># O(1)
def print_first(arr):
    print(arr[0])

# O(N)
def print_all(arr):
    for x in arr:
        print(x)

# O(N²)
def print_pairs(arr):
    for i in arr:
        for j in arr:
            print(i, j)

# O(log N) – 이진 탐색
def binary_search(arr, target):
    left, right = 0, len(arr) - 1
    while left &lt;= right:
        mid = (left + right) // 2
        if arr[mid] == target:
            return mid
        elif arr[mid] &lt; target:
            left = mid + 1
        else:
            right = mid - 1
    return -1
</code></pre>
<hr>
<h2 id="공간-복잡도-space-complexity">공간 복잡도 (Space Complexity)</h2>
<ul>
<li>알고리즘이 <strong>추가로 사용하는 메모리 공간</strong>을 분석</li>
<li>입력값은 제외하고, <strong>변수, 배열, 재귀 호출</strong> 등으로 사용되는 메모리만 고려</li>
</ul>
<table>
<thead>
<tr>
<th>예시</th>
<th>공간 복잡도</th>
</tr>
</thead>
<tbody><tr>
<td>변수 1개</td>
<td>O(1)</td>
</tr>
<tr>
<td>길이 N 배열</td>
<td>O(N)</td>
</tr>
<tr>
<td>N x N 이중 배열</td>
<td>O(N²)</td>
</tr>
<tr>
<td>재귀 깊이 N</td>
<td>O(N) (스택 사용)</td>
</tr>
</tbody></table>
<hr>
<h2 id="입력-크기에-따른-복잡도-한계">입력 크기에 따른 복잡도 한계</h2>
<table>
<thead>
<tr>
<th>입력 크기 N</th>
<th>시간 제한 1초 기준 가능 복잡도</th>
</tr>
</thead>
<tbody><tr>
<td>N ≤ 10</td>
<td>O(N!), 완전탐색 가능</td>
</tr>
<tr>
<td>N ≤ 100</td>
<td>O(N³) 가능</td>
</tr>
<tr>
<td>N ≤ 1,000</td>
<td>O(N²) 가능</td>
</tr>
<tr>
<td>N ≤ 100,000</td>
<td>O(N log N) 가능</td>
</tr>
<tr>
<td>N ≤ 1,000,000</td>
<td>O(N), O(1)만 가능</td>
</tr>
</tbody></table>
<hr>
<h2 id="파이썬-내장-함수-시간-복잡도">파이썬 내장 함수 시간 복잡도</h2>
<table>
<thead>
<tr>
<th>함수</th>
<th>시간 복잡도</th>
<th>설명</th>
</tr>
</thead>
<tbody><tr>
<td><code>len(arr)</code></td>
<td>O(1)</td>
<td>길이 반환</td>
</tr>
<tr>
<td><code>append(x)</code></td>
<td>O(1)</td>
<td>맨 뒤 추가</td>
</tr>
<tr>
<td><code>insert(i, x)</code></td>
<td>O(N)</td>
<td>중간 삽입</td>
</tr>
<tr>
<td><code>pop()</code></td>
<td>O(1)</td>
<td>맨 뒤 제거</td>
</tr>
<tr>
<td><code>pop(i)</code></td>
<td>O(N)</td>
<td>중간 제거</td>
</tr>
<tr>
<td><code>remove(x)</code></td>
<td>O(N)</td>
<td>값 찾아 제거</td>
</tr>
<tr>
<td><code>sort()</code></td>
<td>O(N log N)</td>
<td>TimSort</td>
</tr>
<tr>
<td><code>x in arr</code> (리스트)</td>
<td>O(N)</td>
<td>포함 여부 확인</td>
</tr>
<tr>
<td><code>x in set/dict</code></td>
<td>O(1)</td>
<td>해시 기반 탐색</td>
</tr>
</tbody></table>
<hr>
<h2 id="실전-팁-요약">실전 팁 요약</h2>
<ul>
<li>중첩 반복문 줄이기</li>
<li>정렬 후 이진 탐색 적용</li>
<li>set, dict 활용으로 탐색 속도 개선</li>
<li>입력이 많을 경우 <code>sys.stdin.readline()</code>으로 입력 처리 최적화</li>
</ul>
<hr>
<h2 id="핵심-요약">핵심 요약</h2>
<table>
<thead>
<tr>
<th>항목</th>
<th>설명</th>
</tr>
</thead>
<tbody><tr>
<td>시간 복잡도</td>
<td>연산 횟수 (속도 분석)</td>
</tr>
<tr>
<td>공간 복잡도</td>
<td>메모리 사용량</td>
</tr>
<tr>
<td>Big-O 표기법</td>
<td>가장 영향력 있는 항만 남김</td>
</tr>
<tr>
<td>파이썬 주요 함수 복잡도</td>
<td>알고 있어야 성능 분석 가능</td>
</tr>
<tr>
<td>입력 범위에 따른 제한</td>
<td>문제 조건 보고 적절한 알고리즘 판단 필요</td>
</tr>
</tbody></table>
]]></description>
        </item>
        <item>
            <title><![CDATA[반복문과 재귀함수]]></title>
            <link>https://velog.io/@jh_y/%EB%B0%98%EB%B3%B5%EB%AC%B8%EA%B3%BC-%EC%9E%AC%EA%B7%80%ED%95%A8%EC%88%98</link>
            <guid>https://velog.io/@jh_y/%EB%B0%98%EB%B3%B5%EB%AC%B8%EA%B3%BC-%EC%9E%AC%EA%B7%80%ED%95%A8%EC%88%98</guid>
            <pubDate>Sun, 30 Mar 2025 02:52:59 GMT</pubDate>
            <description><![CDATA[<h2 id="반복문-loop">반복문 (Loop)</h2>
<h3 id="반복문의-개념">반복문의 개념</h3>
<ul>
<li>동일한 코드를 여러 번 실행할 때 사용.</li>
<li>파이썬에서는 <code>for</code>, <code>while</code> 두 가지 문법이 기본.</li>
<li>조건이 True인 동안 계속 반복 수행.</li>
</ul>
<h3 id="for-문-기본-구조">for 문 기본 구조</h3>
<pre><code class="language-python">for 변수 in 반복가능한_객체:
    실행할_코드</code></pre>
<pre><code class="language-python">for i in range(5):
    print(i)  # 0부터 4까지 출력</code></pre>
<h3 id="while-문-기본-구조">while 문 기본 구조</h3>
<pre><code class="language-python">while 조건:
    실행할_코드</code></pre>
<pre><code class="language-python">i = 0
while i &lt; 5:
    print(i)
    i += 1</code></pre>
<h3 id="중첩-반복문">중첩 반복문</h3>
<ul>
<li>반복문 안에 또 다른 반복문을 사용하는 형태</li>
<li>완전탐색(브루트포스) 문제에서 자주 활용됨</li>
</ul>
<pre><code class="language-python">for i in range(3):
    for j in range(2):
        print(i, j)
</code></pre>
<h3 id="반복문의-시간-복잡도">반복문의 시간 복잡도</h3>
<table>
<thead>
<tr>
<th>구조</th>
<th>시간 복잡도</th>
</tr>
</thead>
<tbody><tr>
<td>단일 반복문</td>
<td>O(N)</td>
</tr>
<tr>
<td>이중 반복문</td>
<td>O(N²)</td>
</tr>
<tr>
<td>삼중 반복문</td>
<td>O(N³)</td>
</tr>
</tbody></table>
<hr>
<h2 id="재귀-함수-recursion">재귀 함수 (Recursion)</h2>
<h3 id="재귀-함수의-개념">재귀 함수의 개념</h3>
<ul>
<li>함수가 자기 자신을 다시 호출하는 방식.</li>
<li>복잡한 문제를 작게 나누어 처리할 수 있음.</li>
<li>반드시 종료 조건(Base Case)이 필요함.</li>
</ul>
<h3 id="기본-구조">기본 구조</h3>
<pre><code class="language-python">def func():
    if 종료조건:
        return 결과
    else:
        return func()
</code></pre>
<h3 id="팩토리얼-예시">팩토리얼 예시</h3>
<pre><code class="language-python">def factorial(n):
    if n &lt;= 1:
        return 1
    return n * factorial(n - 1)
</code></pre>
<h3 id="재귀-함수의-동작-원리">재귀 함수의 동작 원리</h3>
<ul>
<li>함수가 스택에 쌓이며 호출되고, 종료 조건을 만나면 거꾸로 결과를 반환하며 정리된다.</li>
<li>메모리 구조상 <strong>스택(stack)</strong> 을 사용하며, 깊이가 너무 깊어지면 <code>RecursionError</code> 발생 가능.</li>
</ul>
<hr>
<h2 id="반복문-vs-재귀-함수-비교">반복문 vs 재귀 함수 비교</h2>
<table>
<thead>
<tr>
<th>항목</th>
<th>반복문</th>
<th>재귀 함수</th>
</tr>
</thead>
<tbody><tr>
<td>구조</td>
<td>명시적 반복</td>
<td>함수 내부에서 자기 자신 호출</td>
</tr>
<tr>
<td>종료 조건</td>
<td>명확한 반복 조건</td>
<td>종료 조건(base case) 필요</td>
</tr>
<tr>
<td>메모리</td>
<td>적게 사용</td>
<td>함수 호출 스택 사용</td>
</tr>
<tr>
<td>속도</td>
<td>일반적으로 빠름</td>
<td>느릴 수 있음</td>
</tr>
<tr>
<td>사용 예시</td>
<td>합계, 누적 계산 등</td>
<td>DFS, 분할정복, 트리 탐색 등</td>
</tr>
</tbody></table>
<hr>
<h2 id="예제--1부터-n까지-합-구하기">예제 : 1부터 N까지 합 구하기</h2>
<h3 id="for문">for문</h3>
<pre><code class="language-python">def sum_loop(n):
    total = 0
    for i in range(1, n+1):
        total += i
    return total
</code></pre>
<h3 id="재귀함수">재귀함수</h3>
<pre><code class="language-python">def sum_rec(n):
    if n == 0:
        return 0
    return n + sum_rec(n - 1)
</code></pre>
<hr>
<h2 id="피보나치-수열-재귀">피보나치 수열 (재귀)</h2>
<pre><code class="language-python">def fib(n):
    if n &lt;= 1:
        return n
    return fib(n-1) + fib(n-2)
</code></pre>
<ul>
<li>중복 호출이 많아 성능이 비효율적.</li>
<li>향후 동적 프로그래밍(DP) 또는 메모이제이션으로 개선 가능.</li>
</ul>
<hr>
<h2 id="핵심-요약">핵심 요약</h2>
<ul>
<li>반복문은 조건을 만족하는 동안 반복 실행되는 구조.</li>
<li>재귀 함수는 동일한 문제를 더 작은 문제로 쪼개 자기 자신을 호출하여 해결.</li>
<li>재귀는 구현이 간단해질 수 있으나, 메모리와 성능에 주의가 필요.</li>
<li>알고리즘 문제 풀이 시 반복과 재귀 중 적절한 방식 선택이 중요하다.</li>
</ul>
<hr>
<p>재귀는 <code>DFS</code>, <code>백트래킹</code>, <code>분할정복</code>, <code>트리 탐색</code>과 같은 고급 알고리즘에서 재귀 함수는 필수 도구로 사용된다.</p>
]]></description>
        </item>
        <item>
            <title><![CDATA[문자열]]></title>
            <link>https://velog.io/@jh_y/%EB%AC%B8%EC%9E%90%EC%97%B4</link>
            <guid>https://velog.io/@jh_y/%EB%AC%B8%EC%9E%90%EC%97%B4</guid>
            <pubDate>Sun, 30 Mar 2025 02:48:30 GMT</pubDate>
            <description><![CDATA[<h3 id="문자열이란">문자열이란?</h3>
<ul>
<li><strong>문자(char)의 연속</strong>으로 이루어진 자료, 데이터.</li>
<li>파이썬에서는 문자열(<code>str</code>)이 불변(immutable) 객체이므로, 수정 시 새로운 문자열을 생성.</li>
<li>C 언어에서는 <code>char</code> 배열을 사용하거나 <code>char *</code>를 동적 할당해 사용. (널 문자 <code>\0</code> 로 끝을 표시)</li>
</ul>
<blockquote>
</blockquote>
<pre><code class="language-python">s = &quot;hello&quot;
print(s[1])  # 출력: &#39;e&#39;</code></pre>
<hr>
<h3 id="문자열의-특징">문자열의 특징</h3>
<ol>
<li><strong>인덱스 접근</strong><ul>
<li><code>s[i]</code>로 개별 문자에 접근 가능 (파이썬: 상수 시간, C: 배열 인덱스 접근)</li>
</ul>
</li>
<li><strong>불변성(파이썬)</strong><ul>
<li>문자열을 직접 수정(<code>s[2] = &#39;X&#39;</code>) 불가 → 새로운 문자열을 만들어야 함.</li>
</ul>
</li>
<li><strong>크기(길이)</strong><ul>
<li>파이썬: <code>len(s)</code>로 길이를 쉽게 구함 (O(1)처럼 보이지만 내부 구현에 따라 O(1) 또는 O(n) 가능성).</li>
<li>C: <code>strlen(str)</code> 함수로 길이 계산 (실제로 한 문자씩 순회하므로 O(n)).</li>
</ul>
</li>
<li><strong>문자열 연산 비용</strong><ul>
<li>문자열 연결시, 새로 공간을 할당하고 복사 → 길이에 비례한 시간 소요.</li>
</ul>
</li>
</ol>
<h3 id="요약">요약</h3>
<table>
<thead>
<tr>
<th>특징</th>
<th>설명</th>
</tr>
</thead>
<tbody><tr>
<td><strong>문자 배열</strong></td>
<td>내부적으로는 문자 하나하나를 인덱스로 구분</td>
</tr>
<tr>
<td><strong>0번 인덱스부터 시작</strong></td>
<td><code>s[0]</code>은 첫 글자</td>
</tr>
<tr>
<td><strong>불변(immutable)</strong></td>
<td>문자열을 직접 수정할 수 없음</td>
</tr>
<tr>
<td><strong>슬라이싱 가능</strong></td>
<td>부분 문자열 추출 가능</td>
</tr>
<tr>
<td><strong>많은 내장 함수 지원</strong></td>
<td>문자열을 다루기 위한 다양한 기능 제공</td>
</tr>
</tbody></table>
<hr>
<h3 id="문자열에서-주로-하는-작업">문자열에서 주로 하는 작업</h3>
<ol>
<li><p><strong>탐색</strong></p>
<ul>
<li>특정 문자가 문자열 안에 존재하는지 찾기.</li>
<li><strong>선형 탐색</strong>으로 O(N)</li>
<li>파이썬 내장: <code>s.find(&#39;a&#39;)</code>, <code>&#39;a&#39; in s</code> 등 (내부적으로도 선형 탐색)</li>
</ul>
</li>
<li><p><strong>슬라이싱 (파이썬)</strong></p>
<ul>
<li><code>s[start:end]</code> 형태로 부분 문자열을 구함.</li>
<li>실제로는 새 문자열을 생성 (복사가 발생) → O(N) <blockquote>
<pre><code class="language-python">s = &quot;hello&quot;
print(s[1:4])  # &#39;ell&#39;
print(s[:2])   # &#39;he&#39;
print(s[2:])   # &#39;llo&#39;</code></pre>
</blockquote>
<pre><code></code></pre></li>
</ul>
</li>
<li><p><strong>변환/조작</strong> </p>
<ul>
<li><code>s.replace(old, new)</code>: 부분 문자열을 다른 문자열로 교체 (새로운 문자열 리턴)</li>
<li><code>s.split(delim)</code>: 구분자로 나누어 리스트 형태로 반환</li>
<li><code>s.strip()</code>: 공백이나 특정 문자 제거</li>
</ul>
</li>
<li><p><strong>문자열 뒤집기</strong></p>
<ul>
<li>파이썬: <code>s[::-1]</code> (슬라이싱 응용)</li>
<li>직접 구현 시, O(N)의 시간에 두 인덱스를 바꿔가며 스왑.</li>
</ul>
</li>
</ol>
<h3 id="인덱스-접근">인덱스 접근</h3>
<blockquote>
</blockquote>
<pre><code class="language-python">s = &quot;hello&quot;
print(s[0])  # &#39;h&#39;
print(s[-1]) # &#39;o&#39; (뒤에서 첫 번째 문자)</code></pre>
<hr>
<h3 id="직접-구현-예시-파이썬-내장함수-최소화">직접 구현 예시 (파이썬, 내장함수 최소화)</h3>
<h4 id="문자열-뒤집기">문자열 뒤집기</h4>
<blockquote>
</blockquote>
<pre><code class="language-python">def reverse_string(st):
    reversed_str = &quot;&quot;
    for i in range(len(st)-1, -1, -1):
        reversed_str += st[i]
    return reversed_str
s = &quot;Hello&quot;
print(reverse_string(s))
# &#39;olleH&#39;</code></pre>
<h4 id="문자열-선형-탐색">문자열 선형 탐색</h4>
<blockquote>
</blockquote>
<pre><code class="language-python">def find_char(st, ch):
    &quot;&quot;&quot;st에서 문자 ch를 찾으면 인덱스 반환, 없으면 -1&quot;&quot;&quot;
    for i in range(len(st)):
        if st[i] == ch:
            return i
    return -1
print(find_char(&quot;Hello&quot;, &#39;l&#39;))  # 2 (처음 찾은 &#39;l&#39;)
print(find_char(&quot;Hello&quot;, &#39;z&#39;))  # -1 (존재하지 않음)</code></pre>
<h4 id="부분-문자열substring-확인">부분 문자열(substring) 확인</h4>
<blockquote>
</blockquote>
<pre><code class="language-python">def is_substring(main_str, sub_str):
    &quot;&quot;&quot;main_str에 sub_str이 포함되어 있는지 확인&quot;&quot;&quot;
    M = len(main_str)
    S = len(sub_str)
    for i in range(M - S + 1):
        match = True
        for j in range(S):
            if main_str[i+j] != sub_str[j]:
                match = False
                break
        if match:
            return True
    return False
print(is_substring(&quot;Hello World&quot;, &quot;World&quot;))  # True
print(is_substring(&quot;Hello World&quot;, &quot;Bye&quot;))    # False</code></pre>
<hr>
<h2 id="문자열-관련-파이썬-내장-함수-정리">문자열 관련 파이썬 내장 함수 정리</h2>
<table>
<thead>
<tr>
<th>함수</th>
<th>설명</th>
<th>예시</th>
<th>C언어 대체 방식</th>
</tr>
</thead>
<tbody><tr>
<td><code>len(s)</code></td>
<td>문자열 길이</td>
<td><code>len(&quot;hello&quot;) → 5</code></td>
<td><code>strlen()</code> 함수 사용 또는 직접 카운트</td>
</tr>
<tr>
<td><code>s.upper()</code></td>
<td>대문자로 변환</td>
<td><code>&quot;abc&quot;.upper() → &quot;ABC&quot;</code></td>
<td>반복문 + <code>toupper()</code></td>
</tr>
<tr>
<td><code>s.lower()</code></td>
<td>소문자로 변환</td>
<td><code>&quot;ABC&quot;.lower() → &quot;abc&quot;</code></td>
<td>반복문 + <code>tolower()</code></td>
</tr>
<tr>
<td><code>s.strip()</code></td>
<td>앞뒤 공백 제거</td>
<td><code>&quot;  hi  &quot;.strip() → &quot;hi&quot;</code></td>
<td>반복문으로 공백 체크</td>
</tr>
<tr>
<td><code>s.lstrip()</code></td>
<td>왼쪽 공백 제거</td>
<td><code>&quot;  hi&quot;.lstrip() → &quot;hi&quot;</code></td>
<td>-</td>
</tr>
<tr>
<td><code>s.rstrip()</code></td>
<td>오른쪽 공백 제거</td>
<td><code>&quot;hi  &quot;.rstrip() → &quot;hi&quot;</code></td>
<td>-</td>
</tr>
<tr>
<td><code>s.split()</code></td>
<td>문자열 나누기</td>
<td><code>&quot;a,b,c&quot;.split(&#39;,&#39;) → [&#39;a&#39;,&#39;b&#39;,&#39;c&#39;]</code></td>
<td>직접 파싱 (for + 조건문)</td>
</tr>
<tr>
<td><code>s.find(sub)</code></td>
<td>부분 문자열 위치</td>
<td><code>&quot;abcde&quot;.find(&quot;cd&quot;) → 2</code></td>
<td>직접 구현 (위 예시 참고)</td>
</tr>
<tr>
<td><code>s.replace(a, b)</code></td>
<td>문자열 치환</td>
<td><code>&quot;aabb&quot;.replace(&quot;a&quot;,&quot;c&quot;) → &quot;ccbb&quot;</code></td>
<td>직접 구현 필요</td>
</tr>
<tr>
<td><code>s.isdigit()</code></td>
<td>숫자 여부 확인</td>
<td><code>&quot;123&quot;.isdigit() → True</code></td>
<td>문자 하나하나 확인</td>
</tr>
</tbody></table>
<h3 id="split-함수"><code>split()</code> 함수</h3>
<blockquote>
</blockquote>
<pre><code class="language-python">text = &quot;apple,banana,grape&quot;
result = text.split(&#39;,&#39;)   # ✅ 내장함수
print(result)              # [&#39;apple&#39;, &#39;banana&#39;, &#39;grape&#39;]</code></pre>
<ul>
<li><strong>기본 동작</strong>: <code>split(separator)</code></li>
<li><code>separator</code>로 문자열을 나눠서 리스트 형태로 반환</li>
<li>생략하면 <strong>공백 기준</strong>으로 나눔 → <code>text.split()</code></li>
<li>C언어에서는 문자열 순회하며 구분자를 기준으로 직접 나눠야 함</li>
</ul>
<h3 id="strip-함수"><code>strip()</code> 함수</h3>
<blockquote>
</blockquote>
<pre><code class="language-python">s = &quot;  hello  &quot;
print(s.strip())   # &#39;hello&#39;
print(s.lstrip())  # &#39;hello  &#39;
print(s.rstrip())  # &#39;  hello&#39;</code></pre>
<ul>
<li>문자열 앞뒤의 <strong>공백 문자(또는 지정 문자)</strong>를 제거</li>
<li>내부적으로 문자 하나하나 비교해서 제거</li>
<li>C언어에서는 수동으로 인덱스 조정하면서 공백 건너뛰어야 함</li>
</ul>
<h3 id="문자열-불변immutable의-의미">문자열 불변(Immutable)의 의미</h3>
<blockquote>
</blockquote>
<pre><code class="language-python">s = &quot;hello&quot;
s[0] = &#39;H&#39;  # ❌ 오류! 문자열은 변경 불가
# 대신 이렇게 해야 함
s = &#39;H&#39; + s[1:]  # ✅ 새로운 문자열 생성
print(s)  # 출력: &#39;Hello&#39;</code></pre>
<ul>
<li>파이썬의 문자열은 <strong>값을 바꾸는 게 아니라, 새로 만드는 방식</strong>으로 동작</li>
<li>메모리 관점에서 비효율이 될 수 있음 (C에서는 직접 바꾸는 것이 가능)</li>
</ul>
<hr>
<h3 id="정리">정리</h3>
<table>
<thead>
<tr>
<th>핵심 포인트</th>
<th>설명</th>
</tr>
</thead>
<tbody><tr>
<td>문자열은 불변이다</td>
<td>수정이 아닌 새 문자열을 생성</td>
</tr>
<tr>
<td>파이썬은 많은 내장 함수를 제공</td>
<td>split, strip, replace 등</td>
</tr>
<tr>
<td>내장함수 없이 구현도 가능해야 함</td>
<td>C언어에서는 전부 직접 만들어야 하기 때문</td>
</tr>
<tr>
<td>슬라이싱은 강력한 기능</td>
<td><code>s[1:4]</code>, <code>s[::-1]</code> 등</td>
</tr>
</tbody></table>
<hr>
<h3 id="추가-tip">추가 tip</h3>
<ul>
<li>문자열은 배열처럼 <strong>인덱스로 처리</strong></li>
<li>파이썬에서는 <code>str</code>, C언어에서는 <code>char[]</code>로 다룸</li>
<li><strong>내장함수에 익숙해지되, 함수 없이도 구현하는 습관을 들이기</strong></li>
<li>C언어에서는 문자열 처리할 때 *<em>널문자 <code>\0</code></em>로 종료를 표시함</li>
</ul>
<hr>
<h3 id="c-언어에서의-문자열과-차이">C 언어에서의 문자열과 차이</h3>
<ul>
<li><em>널 문자(<code>\0</code>)*</em>로 문자열의 끝을 표시해야 함.</li>
<li><code>strlen()</code>, <code>strcpy()</code>, <code>strcat()</code> 등 표준 라이브러리 함수를 사용하거나 직접 구현.</li>
<li>수정 가능(배열이므로), 단 ‘버퍼 크기 초과’에 유의해야 함.</li>
</ul>
<blockquote>
<p>예: char str[10] = &quot;Hello&quot;; 라면, 내부적으로 &#39;H&#39; &#39;e&#39; &#39;l&#39; &#39;l&#39; &#39;o&#39; &#39;\0&#39; ... 형태로 저장.</p>
</blockquote>
]]></description>
        </item>
        <item>
            <title><![CDATA[배열(Array)]]></title>
            <link>https://velog.io/@jh_y/%EB%B0%B0%EC%97%B4Array</link>
            <guid>https://velog.io/@jh_y/%EB%B0%B0%EC%97%B4Array</guid>
            <pubDate>Sun, 30 Mar 2025 01:51:42 GMT</pubDate>
            <description><![CDATA[<h3 id="배열이란">배열이란?</h3>
<ul>
<li>동일한 자료형의 요소들을 연속적인 메모리 공간에 저장하는 자료구조</li>
<li>데이터는 <strong>인덱스(index)</strong>로 구분되며, 0부터 시작</li>
<li>같은 자료형(예: 정수, 문자열 등)의 값을 <strong>순서대로 저장</strong>하는 방식</li>
<li>파이썬에서는 내부적으로 동적 배열(Dynamic Array)을 사용하는 <code>list</code>를 통해 구현.</li>
<li>C 언어에서는 배열을 선언 시 <strong>크기</strong>가 고정되고, 한 번 정하면 수정이 불가능.</li>
</ul>
<blockquote>
<p>예시</p>
<ul>
<li>파이썬: <code>arr = [1, 2, 3]</code></li>
<li>C: <code>int arr[5] = {1,2,3,4,5};</code></li>
</ul>
</blockquote>
<hr>
<h3 id="배열의-주요-특징">배열의 주요 특징</h3>
<ol>
<li><strong>인덱스(Index)를 통한 직접 접근 가능</strong><ul>
<li>arr[i] 형태로 O(1)에 접근 가능 
(파이썬도 내부적으로 동적 배열이지만 평균적으로 O(1)).</li>
</ul>
</li>
<li><strong>연속된 메모리</strong><ul>
<li>논리적으로나 물리적으로 연속적이며, 
중간 삽입·삭제 시 요소의 이동이 필요해 <strong>시간 복잡도가 O(N)</strong>이 됨.</li>
</ul>
</li>
<li><strong>탐색</strong><ul>
<li>정렬되지 않은 배열에서는 <strong>선형 탐색</strong>이 보통, O(N).</li>
<li>정렬된 배열이라면 <strong>이진 탐색</strong>으로 O(log N)에 검색 가능.</li>
</ul>
</li>
</ol>
<table>
<thead>
<tr>
<th>특징</th>
<th>설명</th>
</tr>
</thead>
<tbody><tr>
<td><strong>인덱스(index)</strong></td>
<td>배열의 각 요소를 식별하는 번호. 0부터 시작</td>
</tr>
<tr>
<td><strong>연속된 메모리</strong></td>
<td>배열은 메모리상에 연속적으로 저장됨</td>
</tr>
<tr>
<td><strong>빠른 접근</strong></td>
<td>인덱스를 이용해 O(1) 시간에 원소에 접근 가능</td>
</tr>
<tr>
<td><strong>삽입/삭제 비용</strong></td>
<td>중간에 데이터를 추가하거나 삭제하면 뒤의 값을 전부 옮겨야 해서 O(N) 시간이 걸림</td>
</tr>
</tbody></table>
<hr>
<h3 id="메모리-구조">메모리 구조</h3>
<ul>
<li>배열은 인접한 메모리 번지를 차례로 할당받음.</li>
<li>예를 들어, <code>arr[0]</code>은 메모리 주소 1000부터 4바이트 차지, 
<code>arr[1]</code>은 1004부터 4바이트</li>
</ul>
<hr>
<h3 id="배열의-주요-연산">배열의 주요 연산</h3>
<ol>
<li><strong>인덱스 접근 (Access)</strong><blockquote>
<p>arr[i]  # 평균 O(1)</p>
</blockquote>
</li>
<li><strong>탐색 (Search)</strong><ul>
<li><strong>선형 탐색</strong>: 배열 전체를 순회하며 비교 (O(N))</li>
<li><strong>이진 탐색</strong>: 정렬 상태라면 중간값부터 비교 (O(log N))</li>
</ul>
</li>
<li><strong>삽입 (Insert)</strong><ul>
<li>중간에 삽입 시, 뒤쪽 원소들을 한 칸씩 밀어야 함 → O(N)</li>
<li>파이썬 <code>list</code>의 <code>insert()</code> 메서드도 내부적으로 동일 원리</li>
</ul>
</li>
<li><strong>삭제 (Delete)</strong><ul>
<li>특정 위치에서 원소 삭제 후, 뒤쪽 원소들을 한 칸씩 땡겨야 함 → O(N)</li>
</ul>
</li>
</ol>
<hr>
<h3 id="시간-복잡도-요약big-o">시간 복잡도 요약(BIG O)</h3>
<table>
<thead>
<tr>
<th>연산</th>
<th>평균 시간 복잡도</th>
<th>설명</th>
</tr>
</thead>
<tbody><tr>
<td>인덱스 접근</td>
<td>O(1)</td>
<td>배열의 장점 중 하나</td>
</tr>
<tr>
<td>탐색</td>
<td>O(N)</td>
<td>정렬 상태면 이진 탐색으로 O(log N) 가능</td>
</tr>
<tr>
<td>삽입</td>
<td>O(N)</td>
<td>중간 삽입 시 요소 이동 필요</td>
</tr>
<tr>
<td>삭제</td>
<td>O(N)</td>
<td>중간 삭제 시 요소 이동 필요</td>
</tr>
</tbody></table>
<hr>
<h3 id="배열의-기본-연산">배열의 기본 연산</h3>
<h4 id="인덱스-접근">인덱스 접근</h4>
<blockquote>
<p>arr = [10, 20, 30]
print(arr[0])  # 출력: 10</p>
</blockquote>
<ul>
<li><code>arr[0]</code> → 배열의 첫 번째 요소</li>
<li><code>arr[1]</code> → 두 번째 요소</li>
</ul>
<h3 id="길이-구하기len">길이 구하기(len())</h3>
<blockquote>
</blockquote>
<p>print(len(arr))  # 출력: 3</p>
<h3 id="값-변경">값 변경</h3>
<blockquote>
</blockquote>
<p>arr[1] = 50
print(arr)  # 출력: [10, 50, 30]</p>
<hr>
<h3 id="배열-직접-구현">배열 직접 구현</h3>
<h4 id="특정-위치값-삽입">특정 위치값 삽입</h4>
<blockquote>
</blockquote>
<pre><code class="language-python">def insert_at(arr, index, value):
    &quot;&quot;&quot;index 위치에 value를 삽입&quot;&quot;&quot;
    new_arr = []
    for i in range(len(arr)):      # ✅ 내장함수 사용: len()
        if i == index:
            new_arr.append(value)  # ✅ 내장함수 사용: append()
        new_arr.append(arr[i])     # ✅ 내장함수 사용: append()
    return new_arr
arr = [10, 20, 30]
arr = insert_at(arr, 1, 15)
print(arr)  # 출력: [10, 15, 20, 30]</code></pre>
<blockquote>
<p>C언어에서는</p>
</blockquote>
<ul>
<li><code>len()</code> 배열 길이는 직접 변수로 관리하거나 문자열의 경우 <code>\0</code> 만날 때까지 순회</li>
<li><code>append()</code> 배열의 크기를 관리하면서 직접 인덱스 위치에 삽입해야 함</li>
</ul>
<hr>
<h4 id="특정-위치값-삭제">특정 위치값 삭제</h4>
<blockquote>
</blockquote>
<pre><code class="language-python">def delete_at(arr, index):
    &quot;&quot;&quot;index 위치의 요소를 삭제&quot;&quot;&quot;
    new_arr = []
    for i in range(len(arr)):       # ✅ 내장함수 사용: len()
        if i != index:
            new_arr.append(arr[i])  # ✅ 내장함수 사용: append()
    return new_arr
arr = [10, 15, 20, 30]
arr = delete_at(arr, 2)
print(arr)  # 출력: [10, 15, 30]</code></pre>
<blockquote>
<p>C언어에서는</p>
<ul>
<li><code>len()</code> 직접 배열 길이를 세거나, 고정 길이로 선언</li>
<li><code>append()</code> 없이 <code>i</code>번째 값을 <code>i-1</code>에 복사하는 방식으로 직접 이동시켜야 함</li>
</ul>
</blockquote>
<hr>
<h4 id="값-검색">값 검색</h4>
<blockquote>
</blockquote>
<pre><code class="language-python">def find_value(arr, target):
    &quot;&quot;&quot;target 값이 배열에 있는지 확인하고 위치 반환&quot;&quot;&quot;
    for i in range(len(arr)):       # ✅ 내장함수 사용: len()
        if arr[i] == target:
            return i
    return -1
arr = [10, 20, 30]
print(find_value(arr, 30))  # 출력: 2</code></pre>
<blockquote>
<p>C언어에서도 동일하게 for문으로 순회하며 구현 가능</p>
</blockquote>
<hr>
<h3 id="핵심-요약">핵심 요약</h3>
<ul>
<li>배열은 <strong>인덱스를 통한 빠른 접근(O(1))</strong>이 가장 큰 장점.</li>
<li>중간 삽입/삭제가 잦을 경우 <strong>연결 리스트</strong> 같은 다른 자료구조도 고려.</li>
<li><strong>정렬, 탐색</strong> 알고리즘을 구현할 때 배열을 많이 사용함.</li>
</ul>
<hr>
<h3 id="배열-관련-주요-파이썬-내장함수-정리">배열 관련 주요 파이썬 내장함수 정리</h3>
<table>
<thead>
<tr>
<th>함수</th>
<th>설명</th>
<th>예시</th>
</tr>
</thead>
<tbody><tr>
<td><code>len(arr)</code></td>
<td>배열의 길이(요소 개수)를 반환</td>
<td><code>len([1,2,3]) → 3</code></td>
</tr>
<tr>
<td><code>append(x)</code></td>
<td>배열 맨 뒤에 x를 추가</td>
<td><code>arr.append(10)</code></td>
</tr>
<tr>
<td><code>insert(i, x)</code></td>
<td>i번 인덱스에 x 삽입</td>
<td><code>arr.insert(2, 99)</code></td>
</tr>
<tr>
<td><code>pop(i)</code></td>
<td>i번 인덱스 요소 제거 및 반환 (없으면 맨 뒤 제거)</td>
<td><code>arr.pop(1)</code></td>
</tr>
<tr>
<td><code>remove(x)</code></td>
<td>x값을 가진 첫 번째 요소 제거</td>
<td><code>arr.remove(10)</code></td>
</tr>
<tr>
<td><code>index(x)</code></td>
<td>x의 위치(인덱스) 반환</td>
<td><code>arr.index(20)</code></td>
</tr>
<tr>
<td><code>sort()</code></td>
<td>배열을 오름차순 정렬 (원본 수정)</td>
<td><code>arr.sort()</code></td>
</tr>
<tr>
<td><code>reverse()</code></td>
<td>배열을 뒤집음</td>
<td><code>arr.reverse()</code></td>
</tr>
</tbody></table>
<hr>
<h3 id="자주-쓰이는-알고리즘-문제-유형">자주 쓰이는 알고리즘 문제 유형</h3>
<table>
<thead>
<tr>
<th>문제 유형</th>
<th>설명</th>
</tr>
</thead>
<tbody><tr>
<td><strong>최댓값/최솟값 찾기</strong></td>
<td>배열 전체를 순회하며 비교</td>
</tr>
<tr>
<td><strong>누적합 (Prefix Sum)</strong></td>
<td>부분 합을 미리 계산해 빠르게 처리</td>
</tr>
<tr>
<td><strong>정렬</strong></td>
<td>배열 정렬 후 탐색 또는 조건 비교</td>
</tr>
<tr>
<td><strong>슬라이딩 윈도우</strong></td>
<td>연속된 부분 배열 처리에 유용</td>
</tr>
</tbody></table>
]]></description>
        </item>
        <item>
            <title><![CDATA[첫 정글 TIL]]></title>
            <link>https://velog.io/@jh_y/%EC%B2%AB-%EC%A0%95%EA%B8%80-TIL</link>
            <guid>https://velog.io/@jh_y/%EC%B2%AB-%EC%A0%95%EA%B8%80-TIL</guid>
            <pubDate>Sun, 30 Mar 2025 01:45:21 GMT</pubDate>
            <description><![CDATA[<h1 id="krafton-jungle">KRAFTON Jungle</h1>
<blockquote>
<p>목표:  </p>
<p>1) 전산학 기본 지식<br>2) 팀워크 능력<br>3) 스스로 문제를 파고드는 자질</p>
</blockquote>
<hr>
<h2 id="전체-일정">전체 일정</h2>
<table>
<thead>
<tr>
<th>구간</th>
<th>주차</th>
<th>주제</th>
<th>일정</th>
</tr>
</thead>
<tbody><tr>
<td>입문</td>
<td>WEEK00</td>
<td>정글 입성</td>
<td>3/10 ~ 3/13</td>
</tr>
<tr>
<td>기초</td>
<td>WEEK01</td>
<td>컴퓨팅 사고로의 전환</td>
<td>3/13 ~ 3/20</td>
</tr>
<tr>
<td></td>
<td>WEEK02</td>
<td>컴퓨팅 사고로의 전환</td>
<td>3/20 ~ 3/27</td>
</tr>
<tr>
<td></td>
<td>WEEK03</td>
<td>컴퓨팅 사고로의 전환</td>
<td>3/27 ~ 4/03</td>
</tr>
<tr>
<td></td>
<td>WEEK04</td>
<td>컴퓨팅 사고로의 전환</td>
<td>4/10 ~ 4/17</td>
</tr>
<tr>
<td>준비</td>
<td>WEEK05</td>
<td>탐험 준비</td>
<td>4/17 ~ 4/24</td>
</tr>
<tr>
<td></td>
<td>WEEK06</td>
<td>탐험 준비</td>
<td>4/24 ~ 5/01</td>
</tr>
<tr>
<td></td>
<td>WEEK07</td>
<td>탐험 준비</td>
<td>5/01 ~ 5/08</td>
</tr>
<tr>
<td></td>
<td>WEEK08</td>
<td>탐험 준비</td>
<td>5/08 ~ 5/15</td>
</tr>
<tr>
<td>고난</td>
<td>WEEK09</td>
<td>정글 끝까지 (OS 핀토스)</td>
<td>5/15 ~ 5/22</td>
</tr>
<tr>
<td></td>
<td>WEEK10</td>
<td>정글 끝까지 (OS 핀토스)</td>
<td>5/22 ~ 5/29</td>
</tr>
<tr>
<td></td>
<td>WEEK11</td>
<td>정글 끝까지 (OS 핀토스)</td>
<td>5/29 ~ 6/05</td>
</tr>
<tr>
<td></td>
<td>WEEK12~13</td>
<td>정글 끝까지 (OS 핀토스)</td>
<td>6/05 ~ 6/19</td>
</tr>
<tr>
<td>강화</td>
<td>WEEK14</td>
<td>실력 다지기</td>
<td>6/19 ~ 6/26</td>
</tr>
<tr>
<td>성장</td>
<td>WEEK15</td>
<td>나만의 무기를 갖기</td>
<td>6/26 ~ 7/03</td>
</tr>
<tr>
<td></td>
<td>WEEK16</td>
<td>나만의 무기를 갖기</td>
<td>7/03 ~ 7/10</td>
</tr>
<tr>
<td></td>
<td>WEEK17</td>
<td>나만의 무기를 갖기</td>
<td>7/10 ~ 7/17</td>
</tr>
<tr>
<td></td>
<td>WEEK18</td>
<td>나만의 무기를 갖기</td>
<td>7/17 ~ 7/24</td>
</tr>
<tr>
<td>마무리</td>
<td>WEEK19</td>
<td>세상으로 뛰어들기</td>
<td>7/24 ~ 7/31</td>
</tr>
</tbody></table>
<p>전체 기간: <strong>2025.03.10 ~ 2025.07.31</strong><br>주요 테마: <strong>CS 기반 이론 → 프로젝트 실습 → 실전 OS 개발 → 개인 기술 무기화</strong></p>
<hr>
<h2 id="간단한-소개">간단한 소개</h2>
<p>저는 크래프톤 정글에서 개발 공부를 하고있는 준비생입니다.
전체적인 개발지식에 대해서 부족한 점이 많아 이 부트캠프에 참여하게 되었습니다.
앞으로 매일 크래프톤 정글에서의 TIL을 올리려고 노력해보려고 합니다. 모두들 화이팅</p>
<h3 id="314일금">3/14일(금)</h3>
<p>3/10일에 입소를 해서 바로 미니프로젝트를 만들었다. 기간은 13일 목요일까지 처음보는 2명의 팀원들과 함께했다.
아쉽고 잘 못한 것 같지만 한편으론 들어오자마자 있었던 큰 과제가 끝난 것 같아 후련했다.
그치만 이제 시작이였다. 정글은 코치가 1대1로 코칭해주지 않는다. 가이드를 제시해 줄 뿐 정글을 헤쳐나가는건 내 몫이다.
금주의 공부 키워드는 배열, 문자열, 반복문과 재귀함수등이 있었다. 
필자는 오늘은 공부를 시작하는 첫날이라 정글에서 제시해준 백준 문제들을 먼저 풀어보았다.
근데 학교에서 배운건 C언어이기도 했고 최근 python은 정글 입학시험 문제에서 본 것 뿐이라 정신없이 검색하며 문제를 풀었다..
아래는 공부한 흔적인데 사실상 정리도 깔끔하게 되어있지 않다. 노트정리를 눈에 들어오게 공부도 해야겠다.
(현재 옵시디언을 눈여겨보고있는 중 이다.)
파이썬이 c언어나 자바보다 쉽다고 알려져있지만 필자는 c로 개발공부를 접해 많이 어색하다.. 
더욱 공부가 필요해 보이고 내가 공부한걸 복습하기 위한 정리방법도 필요하다.
앞으로 D-139일동안 많은 것이 성장했을 것이다. 끌어당김의 법칙 처럼 말이다. 내일도 화이팅👍</p>
]]></description>
        </item>
    </channel>
</rss>