Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[YOOHYOJEONG] WEEK 02 solutions#2400

Merged
YOOHYOJEONG merged 2 commits intoDaleStudy:mainDaleStudy/leetcode-study:mainfrom
YOOHYOJEONG:mainYOOHYOJEONG/leetcode-study:mainCopy head branch name to clipboard
Mar 14, 2026
Merged

[YOOHYOJEONG] WEEK 02 solutions#2400
YOOHYOJEONG merged 2 commits intoDaleStudy:mainDaleStudy/leetcode-study:mainfrom
YOOHYOJEONG:mainYOOHYOJEONG/leetcode-study:mainCopy head branch name to clipboard

Conversation

@YOOHYOJEONG
Copy link
Contributor

@YOOHYOJEONG YOOHYOJEONG commented Mar 9, 2026

๋‹ต์•ˆ ์ œ์ถœ ๋ฌธ์ œ

์ž‘์„ฑ์ž ์ฒดํฌ ๋ฆฌ์ŠคํŠธ

  • Projects์˜ ์˜ค๋ฅธ์ชฝ ๋ฒ„ํŠผ(โ–ผ)์„ ๋ˆŒ๋Ÿฌ ํ™•์žฅํ•œ ๋’ค, Week๋ฅผ ํ˜„์žฌ ์ฃผ์ฐจ๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.
  • ๋ฌธ์ œ๋ฅผ ๋ชจ๋‘ ํ‘ธ์‹œ๋ฉด ํ”„๋กœ์ ํŠธ์—์„œ Status๋ฅผ In Review๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.
  • ์ฝ”๋“œ ๊ฒ€ํ† ์ž 1๋ถ„ ์ด์ƒ์œผ๋กœ๋ถ€ํ„ฐ ์Šน์ธ์„ ๋ฐ›์œผ์…จ๋‹ค๋ฉด PR์„ ๋ณ‘ํ•ฉํ•ด์ฃผ์„ธ์š”.

๊ฒ€ํ† ์ž ์ฒดํฌ ๋ฆฌ์ŠคํŠธ

Important

๋ณธ์ธ ๋‹ต์•ˆ ์ œ์ถœ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋‹ค๋ฅธ ๋ถ„ PR ํ•˜๋‚˜ ์ด์ƒ์„ ๋ฐ˜๋“œ์‹œ ๊ฒ€ํ† ๋ฅผ ํ•ด์ฃผ์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค!

  • ๋ฐ”๋กœ ์ด์ „์— ์˜ฌ๋ผ์˜จ PR์— ๋ณธ์ธ์„ ์ฝ”๋“œ ๋ฆฌ๋ทฐ์–ด๋กœ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.
  • ๋ณธ์ธ์ด ๊ฒ€ํ† ํ•ด์•ผํ•˜๋Š” PR์˜ ๋‹ต์•ˆ ์ฝ”๋“œ์— ํ”ผ๋“œ๋ฐฑ์„ ์ฃผ์„ธ์š”.
  • ํ† ์š”์ผ ์ „๊นŒ์ง€ PR์„ ๋ณ‘ํ•ฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์Šน์ธํ•ด์ฃผ์„ธ์š”.

Copy link
Contributor

@dohyeon2 dohyeon2 left a comment

Choose a reason for hiding this comment

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

๋ฐฐ์šด๋ถ€๋ถ„์„ ์ฃผ์„์— ์ ๋Š” ๋ถ€๋ถ„๋„ ์ธ์ƒ์ ์ž…๋‹ˆ๋‹ค.
์–ด๋–ค ๊ณ ๋ฏผ์„ ๊ฐ€์ง€๊ณ  ์ ‘๊ทผํ•˜์…จ๋Š”์ง€ ์•Œ ์ˆ˜ ์žˆ์–ด์„œ ํฅ๋ฏธ๋กœ์› ์Šต๋‹ˆ๋‹ค.
ํŒŒ์ด์ฌ์ด ํ™•์‹คํžˆ ๊ฐ„๋‹จํ•œ ์ฝ”๋“œ์— ์žˆ์–ด์„œ๋Š” ๊ฐ€๋…์„ฑ์ด ์••๋„์ ์ด๋„ค์š”.


a, b = 1, 2
for i in range(3, n+1):
a, b = b, a+b
Copy link
Contributor

Choose a reason for hiding this comment

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

ํŒŒ์ด์ฌ์˜ ๋‹ค์ค‘ ํ• ๋‹น์ด ํŽธ๋ฆฌํ•˜๋„ค์š”.

left *= nums[i]

right = 1
for i in range(n-1, -1, -1):
Copy link
Contributor

Choose a reason for hiding this comment

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

๊ฐœ์ธ์ ์œผ๋กœ๋Š” for๋ฌธ ์กฐ๊ฑด์—์„œ ๊ฐ์‚ฐํ•˜๋Š” ํ˜•ํƒœ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฑธ ์ง€์–‘ํ•˜๋Š” ํŽธ์ธ๋ฐ,
'๋ช‡๋ฒˆ ๋ฐ˜๋ณตํ•˜๋„๋ก ๋˜์–ด์žˆ๋Š”๊ฐ€?'๋ผ๋Š” ์ธก๋ฉด์—์„œ ๊ฐ€๋…์„ฑ์ด ์กฐ๊ธˆ ๋–จ์–ด์ง„๋‹ค๊ณ  ์ƒ๊ฐํ•˜๊ธฐ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.
ํšจ์ •๋‹˜์€ ์–ด๋–ป๊ฒŒ ์ƒ๊ฐํ•˜์‹œ๋‚˜์š”? ใ…Žใ…Ž ์ƒ๊ฐ์„ ๋‚˜๋ˆ„๊ณ  ์‹ถ์–ด ์ฝ”๋ฉ˜ํŠธ ๋‚จ๊น๋‹ˆ๋‹ค.

for i in range(n):
    idx = n - i
    output[idx] *= right
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

์ข‹์€ ์˜๊ฒฌ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!!
์˜ค๋ฅธ์ชฝ ๋ˆ„์ ๊ณฑ์„ ๊ณ„์‚ฐํ•˜๋ ค๊ณ  ์—ญ์ˆœ์œผ๋กœ ์ˆœํšŒํ•˜๋ฉด์„œ ์ž‘์„ฑํ–ˆ๋Š”๋ฐ ๋ง์”€ํ•ด์ฃผ์‹  ๊ฒƒ์ฒ˜๋Ÿผ ๋ฐ˜๋ณต ํšŸ์ˆ˜ ๊ด€์ ์—์„œ๋Š” ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์งˆ ์ˆ˜ ์žˆ๋‹ค๋Š” ์  ๊ณต๊ฐํ•ฉ๋‹ˆ๋‹ค.

Python์—์„œ๋Š” ๋ณดํ†ต reversed(range(n)) ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ๋„ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์„œ ๊ทธ ๋ถ€๋ถ„๋„ ํ•œ ๋ฒˆ ๊ณ ๋ คํ•ด ๋ณผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!!


class Solution(object):
def isAnagram(self, s, t):
if sorted(s) == sorted(t):
Copy link
Contributor

Choose a reason for hiding this comment

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

sortedํ•จ์ˆ˜๊ฐ€ ๋Œ€๋ถ€๋ถ„์˜ ์–ธ์–ด์—์„œ n log n ์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ๊ฐ€์ง€๊ธฐ ๋•Œ๋ฌธ์—,
๋ณด๋‹ค ๋” ํšจ์œจ์ ์ธ ๋ฐฉ๋ฒ•(O(n))์ด ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hyeri0903 ๋‹˜ ๋•๋ถ„์— Counter๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ •๋ ฌ ์—†์ด O(n) ์‹œ๊ฐ„๋ณต์žก๋„๋กœ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์„ ์•Œ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค!!

๋‘ ๋ถ„ ๋ชจ๋‘ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

@hyeri0903 hyeri0903 self-requested a review March 14, 2026 01:36

a, b = 1, 2
for i in range(3, n+1):
a, b = b, a+b
Copy link
Contributor

Choose a reason for hiding this comment

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

๋‹ค๋ฅธ ๋ณ€์ˆ˜๋ฅผ ํ• ๋‹นํ•˜์ง€ ์•Š๊ณ  ์ด๋ ‡๊ฒŒ๋„ ํ’€์ดํ•  ์ˆ˜ ์žˆ๊ตฐ์š” ใ…Žใ…Ž๐Ÿ‘

def isAnagram(self, s, t):
if sorted(s) == sorted(t):
return True
else:
Copy link
Contributor

@hyeri0903 hyeri0903 Mar 14, 2026

Choose a reason for hiding this comment

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

if ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ํ•œ์ค„๋กœ ์ž‘์„ฑํ• ์ˆ˜๋„ ์žˆ์„๊ฒƒ ๊ฐ™๋„ค์š”!

return sorted(s) == sorted(t)

Counter ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ์‹œ๊ฐ„ ๋ณต์žก๋„๋ฅผ O(n)์œผ๋กœ ์ค„์ผ ์ˆ˜ ์žˆ์„๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

from collections import Counter

def isAnagram(self, s, t):
    return Counter(s) == Counter(t)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

์ •๋ ฌ์„ ์ด์šฉํ•œ ๋ฐฉ์‹์ด ๊ฐ„๋‹จํ•œ ๊ฒƒ ๊ฐ™์•„์„œ ์ด๋ ‡๊ฒŒ ํ’€์—ˆ๋Š”๋ฐ ๋ง์”€ํ•ด์ฃผ์‹  ๊ฒƒ์ฒ˜๋Ÿผ Counter๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด O(n)์œผ๋กœ ๋” ํšจ์œจ์ ์œผ๋กœ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!
๋˜ return sorted(s) == sorted(t)์ฒ˜๋Ÿผ ๋” ๊ฐ„๊ฒฐํ•˜๊ฒŒ ํ‘œํ˜„ํ•  ์ˆ˜๋„ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

์ข‹์€ ๋ฐฉ๋ฒ• ๊ณต์œ ํ•ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

@hyeri0903
Copy link
Contributor

์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ๊น”๋”ํ•˜๊ฒŒ ์ž˜ ํ‘ธ์‹œ์ง€๋งŒ ์†”๋ฃจ์…˜ ์ƒ๋‹จ์— ์‹œ๊ฐ„ ๋ณต์žก๋„, ๊ณต๊ฐ„ ๋ณต์žก๋„ ๊ทธ๋ฆฌ๊ณ  ๊ฐ„๋‹จํ•œ ํ’€์ด ๋ฐฉ๋ฒ•์„ ์ฃผ์„์œผ๋กœ ์ž‘์„ฑํ•˜๊ณ  ํ’€์ดํ•˜๋ฉด ๋” ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค! ๋‹ค์Œ์ฃผ๋„ ํ™”์ดํŒ…ํ•ด์š”๐Ÿ™Œ

@YOOHYOJEONG YOOHYOJEONG merged commit a4cd75f into DaleStudy:main Mar 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.