Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4-kjs254 #14

Merged
merged 1 commit into from
Feb 27, 2024
Merged

4-kjs254 #14

merged 1 commit into from
Feb 27, 2024

Conversation

kjs254
Copy link
Member

@kjs254 kjs254 commented Feb 21, 2024

๐Ÿ”— ๋ฌธ์ œ ๋งํฌ

๊ตฌ๋ช…๋ณดํŠธ

โœ”๏ธ ์†Œ์š”๋œ ์‹œ๊ฐ„

10๋ถ„ + @

list ์ž๋ฃŒํ˜•์œผ๋กœ ํ’€๋ ค๊ณ  ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์œผ๋กœ ์‹œ๋„ํ–ˆ์ง€๋งŒ ์‹œ๊ฐ„์ดˆ๊ณผ๊ฐ€ ๋ฐœ์ƒํ•˜์—ฌ ํ•ด๊ฒฐํ•˜์ง€ ๋ชปํ•˜์˜€์Šต๋‹ˆ๋‹ค.

์ €๋ฒˆ PR์—์„œ ๋ฐฐ์šด ๋‚ด์šฉ์„ ํ† ๋Œ€๋กœ ๋‹ค์‹œ ๋ฌธ์ œ๋ฅผ ์ ‘๊ทผํ•˜์˜€๋”๋‹ˆ 10๋ถ„๋‚ด๋กœ ์›๋งŒํ•˜๊ฒŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

โœจ ์ˆ˜๋„ ์ฝ”๋“œ

1. ๋ฌธ์ œ ํ•ด์„

์‚ฌ๋žŒ๋“ค์˜ ๋ชธ๋ฌด๊ฒŒ ๋ฐฐ์—ด people๊ณผ ๊ตฌ๋ช…๋ณดํŠธ์˜ ๋ฌด๊ฒŒ ์ œํ•œ limit๊ฐ€ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค.

๊ตฌ๋ช…๋ณดํŠธ์˜ ์ •์›์€ ์ตœ๋Œ€ 2๋ช… ์ž…๋‹ˆ๋‹ค.

ํ•„์š”ํ•œ ๊ตฌ๋ช…๋ณดํŠธ ๊ฐœ์ˆ˜์˜ ์ตœ์†Ÿ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด people์ด[100,60,90,50,20,10] , limit๊ฐ€ 100์œผ๋กœ ์ฃผ์–ด์ง„๋‹ค๋ฉด, [100], [90,10], [60,20], [50] ์œผ๋กœ ๋ชจ๋“  ์ธ์›์„ ์˜ฎ๊ธธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ 4๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

  1. ๊ตฌ๋ช…๋ณดํŠธ์˜ ์ •์›์€ 2๋ช…
  2. ๊ตฌ๋ช…๋ณดํŠธ์˜ ๋ฌด๊ฒŒ์ œํ•œ limit

๋‹ค์Œ๊ณผ ๊ฐ™์€ ์กฐ๊ฑด์—์„œ limit๋ฅผ ๋„˜์ง€๋งŒ ์•Š์œผ๋ฉด ๋‹ค๋ฅธ ์กฐ๊ฑด์€ ์—†๊ธฐ์— people์˜ ์ตœ๋Œ“๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’์— ์ ‘๊ทผํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ํ•ด๊ฒฐํ•ฉ๋‹ˆ๋‹ค.

people์˜ ์ตœ๋Œ“๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’์— ๋™์‹œ์— ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•ด deque์„ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•˜๋Š” ๋ฐฉ์‹์„ ์„ ํƒํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.



2. ์ˆ˜๋„ ์ฝ”๋“œ

  1. people์„ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.

  2. people์˜ ์ตœ๋Œ€๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’์˜ ํ•ฉ์ด limit๋ณด๋‹ค ํด ๊ฒฝ์šฐ answer์— 2๋ฅผ ๋”ํ•ฉ๋‹ˆ๋‹ค.

  • 2.1. ๊ทธ๋ ‡์ง€ ์•Š์„ ๊ฒฝ์šฐ 1์„ ๋”ํ•ฉ๋‹ˆ๋‹ค.

deque์˜ pop()๊ณผ popleft()๊ฐ€ ๋™์‹œ์— ์ด๋ฃจ์–ด์ง€๊ธฐ์— people์˜ ๊ธธ์ด๊ฐ€ 1์ผ ๋•Œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•จ์„ ๋ฐœ๊ฒฌํ•˜์—ฌ ๋‹ค์Œ์„ ํ†ตํ•ด ํ•ด๊ฒฐํ•˜์˜€์Šต๋‹ˆ๋‹ค.

people์˜ ๊ธธ์ด๊ฐ€ 1๋ณด๋‹ค ํด ๊ฒฝ์šฐ์—๋งŒ ์ตœ๋Œ€๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’์„ ๋”ํ•œ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด answer์— 1์„ ๋”ํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

์ „์ฒด ์ฝ”๋“œ

from collections import deque

def solution(people, limit):
    answer = 0
    people = deque(sorted(people))
    
    while len(people)>1:
        if people[0]+people[-1]<=limit:
            people.pop()
            people.popleft()
            answer+=1
        else:
            people.pop()
            answer+=1
        
    return answer+1 if people else answer



3. ์ถ”๊ฐ€

def solution(people, limit):
    answer = 0
    people = sorted(people, reverse = True)
    while len(people)>1:
        if people[0]+people[-1] > limit:
            people.remove(people[0])
            answer +=1
        elif people[0]+people[-1] <= limit:
            people.remove(people[0])
            people.remove(people[-1])
            answer +=1
    return answer+1 if people else answer

์ œ์ผ ์ฒ˜์Œ ๊ตฌ์ƒํ–ˆ๋˜ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

์ •ํ™•๋„์—์„œ๋Š” ๋งŒ์ ์„ ๋ฐ›์•˜์ง€๋งŒ ์‹œ๊ฐ„์ดˆ๊ณผ๊ฐ€ ํ•ญ์ƒ ๋ฐœ์ƒํ•˜์˜€๊ณ  ํ•ด๊ฒฐํ•˜์ง€ ๋ชปํ•˜์˜€์Šต๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒƒ๋งŒ์œผ๋กœ ์ฝ”๋“œ ๊ฐ€๋…์„ฑ ๋ฐ ์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ์ƒ๋‹นํžˆ ์ค„์ผ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ“š ์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ๋œ ๋‚ด์šฉ

๋‹ค๋ฅธ ์‚ฌ๋žŒ์˜ ํ’€์ด๋ฅผ ์ฐธ๊ณ ํ•˜๋Š” ์ค‘ ๋ณด๊ณ  ๋‹ค์†Œ ๋†€๋ผ์šด ์ฝ”๋“œ๋ฅผ ๋ฐœ๊ฒฌํ•˜์—ฌ ๋‚จ๊น๋‹ˆ๋‹ค.

def solution(people, limit) :
    answer = 0
    people.sort()

    a = 0
    b = len(people) - 1
    while a < b :
        if people[b] + people[a] <= limit :
            a += 1
            answer += 1
        b -= 1
    return len(people) - answer

people์„ ์˜ค๋ฆ„์ฐจ์ˆœํ•˜๋Š” ๊ณผ์ •์„ ๋˜‘๊ฐ™์Šต๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ ๋ณดํŠธ๋ฅผ ํƒ‘์Šนํ•˜๋Š” ์ง‘ํ•ฉ์˜ ์ˆ˜๋ฅผ answer์— ์ €์žฅํ•œ ๋’ค, ๋ณดํŠธ ์ •์›์ด 2๋ช…์ธ ์ ์„ ํŒŒ์•…ํ•˜์—ฌ people์˜ ์ „์ฒด ๊ธธ์ด์— answer๋ฅผ ๋นผ์ฃผ๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์˜€์Šต๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ ๋…ธํ•˜์šฐ๋ฅผ ๋” ํ„ฐ๋“ํ–ˆ์œผ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.

@9kyo-hwang
Copy link

image

PR ์ œ๋ชฉ ๋ฐ”๊ฟ”์ฃผ์„ธ์š”!

@tgyuuAn tgyuuAn changed the title 2024-02-21 ๊ตฌ๋ช…๋ณดํŠธ 4-ks254 Feb 22, 2024
@tgyuuAn tgyuuAn changed the title 4-ks254 4-kjs254 Feb 22, 2024
Copy link
Collaborator

@rivkms rivkms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โœ”๏ธ ํ›Œ๋ฅญํ•œ ์ฝ”๋“œ๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

โœ”๏ธ PR์—์„œ remove๋ฅผ ์ด์šฉํ•˜์˜€์„ ๋•Œ์˜ ์‹œ๊ฐ„ ์ดˆ๊ณผ ๋ฌธ์ œ๋Š” list์˜ remove๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํ•œ ์š”์†Œ๋ฅผ ์ง€์šฐ๊ณ  ๊ทธ ๋’ค์˜ ์š”์†Œ๋“ค์„ ์•ž์œผ๋กœ ๊ฐ€์ ธ์˜ค๋Š” ๊ณผ์ •์ด ํ•„์š”ํ•˜์—ฌ โ€ผ๏ธO(n)โ€ผ๏ธ์˜ ์‹œ๊ฐ„๋ณต์žก๋„๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.
ํ•˜์ง€๋งŒ deque๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด pop๊ณผ popleft๋Š” double linked-list๋กœ ๊ตฌํ˜„ํ•˜์˜€๊ธฐ ๋•Œ๋ฌธ์— โ€ผ๏ธO(1)โ€ผ๏ธ์˜ ์‹œ๊ฐ„๋ณต์žก๋„๊ฐ€ ๋ฐœ์ƒํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ ์ด๋Ÿฌํ•œ ์‹œ๊ฐ„๋ณต์žก๋„์— ๋”ฐ๋ผ ์ œ๊ณต๋˜๋Š” ์ž…๋ ฅ์ด ๋งŽ์•„์ง€๋ฉด ์‹œ๊ฐ„์ด ๋Š˜์–ด๋‚˜ ์‹œ๊ฐ„์ดˆ๊ณผ๊ฐ€ ๋œจ๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๐Ÿ“ ์•„๋ž˜์˜ ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•ด๋ณด์‹œ๋ฉด ๋” ๋„์›€์ด ๋  ๊ฒƒ ๊ฐ™๋„ค์š”.

1๏ธโƒฃ ํŒŒ์ด์ฌ pop์˜ ์‹œ๊ฐ„ ๋ณต์žก๋„์— ๋Œ€ํ•œ ๊ณ ์ฐฐ(๋งจ ๋’ค, ์ค‘๊ฐ„, ๋งจ ์•ž ์œ„์น˜ ๋น„๊ต ๋ฐ
2๏ธโƒฃ [ํŒŒ์ด์ฌ] ๋ฑ vs ๋ฆฌ์ŠคํŠธ ์†๋„ ์ฐจ์ด? (deque vs list speed ์ฐจ์ด)

โœ”๏ธ๋งˆ์ง€๋ง‰์— ์ข‹์€ ์ฝ”๋“œ๋ผ๊ณ  ์•Œ๋ ค์ฃผ์…จ๋˜ ์ฝ”๋“œ๋Š” ์•„๋งˆ ํˆฌํฌ์ธํ„ฐ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
๋ฐฐ์—ด์„ ๋”ฐ๋กœ ์ˆ˜์ •ํ•˜์ง€ ์•Š๊ณ  ํฌ์ธํ„ฐ๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ฐ’์„ ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์ด์—ฌ์„œ list๋ฅผ ์‚ฌ์šฉํ•˜์‹ค ๊ฒฝ์šฐ ์ด ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์‹œ๋Š”๊ฒŒ ๋” ํšจ์œจ์ ์ผ ๊ฒƒ ๊ฐ™๋„ค์š”.

โœ”๏ธ ๋ฌผ๋ก  deque๋ฅผ ์ด์šฉํ•˜์—ฌ ํ’€์ดํ•˜์‹  ๋ฐฉ๋ฒ•๋„ ์ข‹์€ ๋ฐฉ๋ฒ•์ด๋ผ ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ํ’€์ด๋ฅผ ์•Œ๋ ค์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค.๐Ÿ˜

@kjs254
Copy link
Member Author

kjs254 commented Feb 24, 2024

โœ”๏ธ ํ›Œ๋ฅญํ•œ ์ฝ”๋“œ๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

โœ”๏ธ PR์—์„œ remove๋ฅผ ์ด์šฉํ•˜์˜€์„ ๋•Œ์˜ ์‹œ๊ฐ„ ์ดˆ๊ณผ ๋ฌธ์ œ๋Š” list์˜ remove๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํ•œ ์š”์†Œ๋ฅผ ์ง€์šฐ๊ณ  ๊ทธ ๋’ค์˜ ์š”์†Œ๋“ค์„ ์•ž์œผ๋กœ ๊ฐ€์ ธ์˜ค๋Š” ๊ณผ์ •์ด ํ•„์š”ํ•˜์—ฌ โ€ผ๏ธO(n)โ€ผ๏ธ์˜ ์‹œ๊ฐ„๋ณต์žก๋„๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ deque๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด pop๊ณผ popleft๋Š” double linked-list๋กœ ๊ตฌํ˜„ํ•˜์˜€๊ธฐ ๋•Œ๋ฌธ์— โ€ผ๏ธO(1)โ€ผ๏ธ์˜ ์‹œ๊ฐ„๋ณต์žก๋„๊ฐ€ ๋ฐœ์ƒํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋Ÿฌํ•œ ์‹œ๊ฐ„๋ณต์žก๋„์— ๋”ฐ๋ผ ์ œ๊ณต๋˜๋Š” ์ž…๋ ฅ์ด ๋งŽ์•„์ง€๋ฉด ์‹œ๊ฐ„์ด ๋Š˜์–ด๋‚˜ ์‹œ๊ฐ„์ดˆ๊ณผ๊ฐ€ ๋œจ๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๐Ÿ“ ์•„๋ž˜์˜ ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•ด๋ณด์‹œ๋ฉด ๋” ๋„์›€์ด ๋  ๊ฒƒ ๊ฐ™๋„ค์š”.

1๏ธโƒฃ ํŒŒ์ด์ฌ pop์˜ ์‹œ๊ฐ„ ๋ณต์žก๋„์— ๋Œ€ํ•œ ๊ณ ์ฐฐ(๋งจ ๋’ค, ์ค‘๊ฐ„, ๋งจ ์•ž ์œ„์น˜ ๋น„๊ต ๋ฐ
2๏ธโƒฃ [ํŒŒ์ด์ฌ] ๋ฑ vs ๋ฆฌ์ŠคํŠธ ์†๋„ ์ฐจ์ด? (deque vs list speed ์ฐจ์ด)

โœ”๏ธ๋งˆ์ง€๋ง‰์— ์ข‹์€ ์ฝ”๋“œ๋ผ๊ณ  ์•Œ๋ ค์ฃผ์…จ๋˜ ์ฝ”๋“œ๋Š” ์•„๋งˆ ํˆฌํฌ์ธํ„ฐ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋ฐฐ์—ด์„ ๋”ฐ๋กœ ์ˆ˜์ •ํ•˜์ง€ ์•Š๊ณ  ํฌ์ธํ„ฐ๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ฐ’์„ ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์ด์—ฌ์„œ list๋ฅผ ์‚ฌ์šฉํ•˜์‹ค ๊ฒฝ์šฐ ์ด ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜์‹œ๋Š”๊ฒŒ ๋” ํšจ์œจ์ ์ผ ๊ฒƒ ๊ฐ™๋„ค์š”.

โœ”๏ธ ๋ฌผ๋ก  deque๋ฅผ ์ด์šฉํ•˜์—ฌ ํ’€์ดํ•˜์‹  ๋ฐฉ๋ฒ•๋„ ์ข‹์€ ๋ฐฉ๋ฒ•์ด๋ผ ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ํ’€์ด๋ฅผ ์•Œ๋ ค์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค.๐Ÿ˜

list์™€ deque์˜ ์ฐจ์ด๋ฅผ ์ƒ์„ธํ•˜๊ฒŒ ์„ค๋ช…ํ•ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

ํˆฌํฌ์ธํ„ฐ ์•Œ๊ณ ๋ฆฌ์ฆ˜๋„ ์ด๋ฒˆ์— ์ฒ˜์Œ ๋“ฃ๊ฒŒ ๋˜์—ˆ๋Š”๋ฐ ์ข‹์€ ๊ณต๋ถ€๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ์•Œ๊ณ  ์ฝ”๋“œ๋ฅผ ๋‹ค์‹œ๋ณด๋‹ˆ ํ›จ์”ฌ ์ดํ•ดํ•˜๊ธฐ ์‰ฝ๋„ค์š” โ— โ— โ—

Copy link
Collaborator

@YIM2UL2ET YIM2UL2ET left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋งˆ์ง€๋ง‰์— ์•Œ๋ ค์ฃผ์‹  ์ฝ”๋“œ๋„ ์ถฉ๋ถ„ํžˆ ์ข‹์ง€๋งŒ, deque๋ฅผ ์ด์šฉํ•œ ์ด ๋ฐฉ๋ฒ•๋„ ์ถฉ๋ถ„ํžˆ ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ์˜คํžˆ๋ ค ์ดํ•ดํ•˜๋Š” ๋ฉด์—์„œ๋Š” ํ’€์ดํ•˜์‹  ์ฝ”๋“œ๊ฐ€ ๋” ๊น”๋”ํ•˜๊ณ , ๊ต‰์žฅํžˆ ์ดํ•ดํ•˜๊ธฐ ์‰ฌ์šด ์ฝ”๋“œ๋ผ๊ณ  ์ƒ๊ฐ๋ฉ๋‹ˆ๋‹ค. ์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator

@mong3125 mong3125 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ˆ˜๋„ ์ฝ”๋“œ ํ’€์ด๋Š” ์ง๊ด€์ ์ด๋ผ ์ดํ•ด๊ฐ€ ์ž˜ ๋˜๋Š”๋ฐ ์ƒˆ๋กญ๊ฒŒ ์ดํ•ดํ•œ ๋ฐฉ๋ฒ•์€ ์ž˜ ์ดํ•ด๊ฐ€ ์•ˆ๊ฐ€๋„ค์š”. ํ˜น์‹œ ๊ตฌ์ฒด์ ์œผ๋กœ ์„ค๋ช…ํ•ด์ฃผ์‹ค ์ˆ˜ ์žˆ์„๊นŒ์š”..?

@kjs254
Copy link
Member Author

kjs254 commented Feb 27, 2024

์ˆ˜๋„ ์ฝ”๋“œ ํ’€์ด๋Š” ์ง๊ด€์ ์ด๋ผ ์ดํ•ด๊ฐ€ ์ž˜ ๋˜๋Š”๋ฐ ์ƒˆ๋กญ๊ฒŒ ์ดํ•ดํ•œ ๋ฐฉ๋ฒ•์€ ์ž˜ ์ดํ•ด๊ฐ€ ์•ˆ๊ฐ€๋„ค์š”. ํ˜น์‹œ ๊ตฌ์ฒด์ ์œผ๋กœ ์„ค๋ช…ํ•ด์ฃผ์‹ค ์ˆ˜ ์žˆ์„๊นŒ์š”..?

์ˆ˜๋„ ์ฝ”๋“œ ํ’€์ด๋Š” ์ง๊ด€์ ์ด๋ผ ์ดํ•ด๊ฐ€ ์ž˜ ๋˜๋Š”๋ฐ ์ƒˆ๋กญ๊ฒŒ ์ดํ•ดํ•œ ๋ฐฉ๋ฒ•์€ ์ž˜ ์ดํ•ด๊ฐ€ ์•ˆ๊ฐ€๋„ค์š”. ํ˜น์‹œ ๊ตฌ์ฒด์ ์œผ๋กœ ์„ค๋ช…ํ•ด์ฃผ์‹ค ์ˆ˜ ์žˆ์„๊นŒ์š”..?

people์„ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ ๋’ค 0๋ฒˆ ์ธ๋ฑ์Šค ํฌ์ธํ„ฐ๋ฅผ a, ๋งˆ์ง€๋ง‰ ์ธ๋ฑ์Šค ํฌ์ธํ„ฐ๋ฅผ b๋กœ ์ดˆ๊ธฐํ™”ํ•ฉ๋‹ˆ๋‹ค.

์ด ํฌ์ธํ„ฐ๋ฅผ ์ด์šฉํ•˜์—ฌ ์ตœ๋Œ€๊ฐ’๊ณผ ์ตœ์†Ÿ๊ฐ’์„ ๋”ํ•ด์„œ limit๋ณด๋‹ค ํฌ๋‹ค๋ฉด a์™€ b๋ฅผ ๊ฐ๊ฐ 1์”ฉ ์ฆ๊ฐ€์‹œํ‚ค๊ณ  ๊ทธ๋ ‡์ง€ ์•Š๋‹ค๋ฉด a๋งŒ ์ฆ๊ฐ€์‹œํ‚ค๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.

@kjs254 kjs254 merged commit dd6a551 into main Feb 27, 2024
1 check passed
@kjs254 kjs254 deleted the 4-kjs254 branch February 27, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants