Skip to content

[Hyeri1ee] WEEK 01 solutions#2379

Merged
Hyeri1ee merged 5 commits intoDaleStudy:mainfrom
Hyeri1ee:main
Mar 7, 2026
Merged

[Hyeri1ee] WEEK 01 solutions#2379
Hyeri1ee merged 5 commits intoDaleStudy:mainfrom
Hyeri1ee:main

Conversation

@Hyeri1ee
Copy link
Contributor

@Hyeri1ee Hyeri1ee commented Mar 5, 2026

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@Hyeri1ee Hyeri1ee requested a review from reeseo3o March 7, 2026 06:26
public boolean containsDuplicate(int[] nums) {

for(int i=0; i<nums.length; i++){
if (!save.contains(nums[i])) save.add(nums[i]);
Copy link
Contributor

Choose a reason for hiding this comment

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

여기서는 Set.add의 반환값을 활용해서

if (!save.add(nums[i])) return true;

처럼 한 줄로 줄여볼 수도 있을 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

set의 add를 통해 한 줄로 줄여볼 수도 있네요! 조언 감사합니다

class Solution {
static int[] answer = new int[2];
public int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> maps = new HashMap<>();//num , index
Copy link
Contributor

Choose a reason for hiding this comment

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

HashMap을 사용해서 {값 -> 인덱스}를 저장해 두고 한 번의 순회로 정답을 찾는 방식이라 시간 복잡도가 O(n)으로 잘 설계된 풀이로 보입니다!
특히 int t = target - nums[i];로 필요한 값을 계산해 두고 containsKey로 바로 확인하는 흐름이 깔끔하고 좋은 것 같습니다! 👍

@Hyeri1ee Hyeri1ee merged commit 80454ac into DaleStudy:main Mar 7, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from Solving to Completed in 리트코드 스터디 7기 Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

2 participants