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

[DaleSeo] WEEK 1 Solutions#2348

Merged
DaleSeo merged 1 commit intomainDaleStudy/leetcode-study:mainfrom
week1DaleStudy/leetcode-study:week1Copy head branch name to clipboard
Mar 4, 2026
Merged

[DaleSeo] WEEK 1 Solutions#2348
DaleSeo merged 1 commit intomainDaleStudy/leetcode-study:mainfrom
week1DaleStudy/leetcode-study:week1Copy head branch name to clipboard

Conversation

@DaleSeo
Copy link
Member

@DaleSeo DaleSeo commented Feb 28, 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.

๊ฐ„๋‹จํ•œ ๋ฌธ์ œ์ง€๋งŒ, Rust๋ฅผ ์žฌ๋ฏธ์žˆ๊ฒŒ ์ž˜ ์‚ดํŽด๋ณผ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
์ข‹์€ ํ’€์ด ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

for (i, &num) in nums.iter().enumerate() {
let complement = target - num;
if let Some(&j) = indices.get(&complement) {
return vec![j as i32, i as i32];
Copy link
Contributor

Choose a reason for hiding this comment

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

'์ด ๋ถ€๋ถ„์—์„œ ์™œ ์ •๋ ฌ์„ ์•ˆํ•˜์ง€?'๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๋Š”๋ฐ

You can return the answer in any order.

์ตœ๋ฉด์— ๊ฑธ๋ฆฐ ๊ฒƒ ์ฒ˜๋Ÿผ ์ •๋ ฌ์„ ํ•ด๋ฒ„๋ ธ๋Š”๋ฐ,,
์ด๋Ÿฐ ์กฐ๊ฑด์ด ์žˆ๋„ค์š”.

์‹ฌ์ง€์–ด ์ˆœ์ฐจ์ ์œผ๋กœ ์กฐํšŒํ•˜๋ฉฐ index๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š”๊ฑฐ๋ผ
์ •๋ ฌ์„ ์•ˆํ•ด๋„ ๊ฒฐ๊ณผ๊ฐ€ ๊ฐ™๋‹ค๋Š” ๋‹น์—ฐํ•œ ์‚ฌ์‹ค์„ ์•Œ๊ฒŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค..

// TC: O(n)
// SC: O(n)
impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Vec<i32>์˜ ์˜๋ฏธ๋Š” ์•Œ๊ฒ ๋Š”๋ฐ,
i32๋ผ๋Š” ํ‘œํ˜„์ด ๊ฝค๋‚˜ ๋ฌด์„ญ๋„ค์š”.

ํ™•์‹คํžˆ ๋‹ค๋ฅธ ์ธ๊ธฐ์žˆ๋Š” ์–ธ์–ด๋“ค์— ๋น„ํ•ด ์ €์ˆ˜์ค€์„ ๋‹ค๋ฃฌ๋‹ค๋Š” ๊ฑธ ์•Œ ์ˆ˜ ์žˆ๋„ค์š”.

Copy link
Member Author

Choose a reason for hiding this comment

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

๋„ค, ์ฐธ ๊ฐ•๋ ฅํ•œ ๋งŒํผ ์†์ด ๋งŽ์ด ๊ฐ€๋Š” ์–ธ์–ด์ž…๋‹ˆ๋‹ค ๐Ÿฅฒ

pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut indices = HashMap::new();
for (i, &num) in nums.iter().enumerate() {
let complement = target - num;
Copy link
Contributor

Choose a reason for hiding this comment

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

complement๋ผ๋Š” ํ‘œํ˜„์„ ์•Œ์•„๊ฐ‘๋‹ˆ๋‹ค.

Copy link
Member Author

Choose a reason for hiding this comment

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

ํ‰์ƒ ์‹œ์—๋Š” ๊ฑฐ์˜ ์“ธ ์ผ์ด ์—†๋Š” ๋‹จ์–ด์ธ๋ฐ, ์ €๋„ ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ ์ค€๋น„ํ•˜๋ฉด์„œ ๋ฐฐ์› ์Šต๋‹ˆ๋‹ค :)

let mut indices = HashMap::new();
for (i, &num) in nums.iter().enumerate() {
let complement = target - num;
if let Some(&j) = indices.get(&complement) {
Copy link
Contributor

Choose a reason for hiding this comment

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

rust์˜ null์ฐธ์กฐ ๋ฐฉ์ง€๊ฐ€ ๊ฝค ํŽธ๋ฆฌํ•œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Copy link
Member Author

Choose a reason for hiding this comment

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

๋„ค, Rust์˜ ๊ฐ•์  ์ค‘ ํ•˜๋‚˜์ฃ  ใ…Žใ…Ž

@DaleSeo
Copy link
Member Author

DaleSeo commented Mar 4, 2026

@dohyeon2 ๋‹˜, ๋ฆฌ๋ทฐ ๊ฐ์‚ฌํž™๋‹ˆ๋‹ค! ์“ฐ์‹œ๋Š” ์–ธ์–ด๊ฐ€ ์•„๋‹ˆ์‹ ๋ฐ๋„ ์ฝ”๋ฉ˜ํŠธ๊นŒ์ง€ ๋‹ฌ์•„์ฃผ์‹œ๊ณ  ๋ฆฌ๋ทฐ ํƒœ๋„๊ฐ€ ๋„˜ ์ข‹์œผ์‹  ๊ฒƒ ๊ฐ™์•„์š”. ์•ž์œผ๋กœ ๋‹ค๋ฅธ ๋ฉค๋ฒ„๋“ค๊ป˜๋„ ์ด๋Ÿฐ ์ข‹์€ ๊ฒฝํ—˜ ๋‚˜๋ˆ ์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋•๋ถ„์— ๊ธฐ๋ถ„ ์ข‹๋„ค์š” :)

@DaleSeo DaleSeo merged commit 4d43cb6 into main Mar 4, 2026
3 checks passed
@DaleSeo DaleSeo deleted the week1 branch March 4, 2026 04:16
@dohyeon2
Copy link
Contributor

dohyeon2 commented Mar 4, 2026

@dohyeon2 ๋‹˜, ๋ฆฌ๋ทฐ ๊ฐ์‚ฌํž™๋‹ˆ๋‹ค! ์“ฐ์‹œ๋Š” ์–ธ์–ด๊ฐ€ ์•„๋‹ˆ์‹ ๋ฐ๋„ ์ฝ”๋ฉ˜ํŠธ๊นŒ์ง€ ๋‹ฌ์•„์ฃผ์‹œ๊ณ  ๋ฆฌ๋ทฐ ํƒœ๋„๊ฐ€ ๋„˜ ์ข‹์œผ์‹  ๊ฒƒ ๊ฐ™์•„์š”. ์•ž์œผ๋กœ ๋‹ค๋ฅธ ๋ฉค๋ฒ„๋“ค๊ป˜๋„ ์ด๋Ÿฐ ์ข‹์€ ๊ฒฝํ—˜ ๋‚˜๋ˆ ์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋•๋ถ„์— ๊ธฐ๋ถ„ ์ข‹๋„ค์š” :)

์ข‹๊ฒŒ ๋ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! ์ข‹์€ ์˜ํ–ฅ๋ ฅ์„ ๋ผ์น  ์ˆ˜ ์žˆ๋„๋ก ๊ด€์‹ฌ๊ฐ€์ง€๊ณ  ์ž„ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค~

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.

2 participants

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