Skip to content

Add day20 #70

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

Merged
merged 1 commit into from
Jul 22, 2024
Merged

Add day20 #70

merged 1 commit into from
Jul 22, 2024

Conversation

summer2788
Copy link
Contributor

Day-20 / 박종은

문제 번호

  1. 17_LetterCombinationsofaPhoneNumber
  2. 131_PalindromePartitioning
  3. 355_DesignTwitter

(Optional) 공유하고 싶은 내용

355_DesignTwitter

시간을 많이 날린 정말 킹받는 문제다. 물론 내 경험 부족 탓이다.
문제는 해당 함수가 $3 * 10^4$ 번 호출 될 것이라 했다.
worst case 를 고려했을 때 주어진 tweet 의 최대 개수는 $10^4$ 개이므로 최종적으로 $3 * 10^4 * 10^4$ 번 호출되어서 우리가 흔히 생각하는 time limit 인 $10^8$(약 1초) 을 초과하게 된다. 그래서 나는 무조건 O($logn$) 의 알고리즘을 써야된다고 생각했다. 그러나 정작 solution 은 O(n) 이였다.
이미 생각했던 솔루션이지만 당연히 안될 줄 알고 건너뛴 것이다. 너무 time complexity 에 얽매이지 않고 더 나은 solution 이 도저히 생각안나면 최선의 solution 으로 돌려봐야겠다.

17_LetterCombinationsofaPhoneNumber

c++ 에서 string 에 array 처럼 pop_back()push_back() 을 할 수 있다는 사실을 처음 알았다. 나는 아직 잼민이구나

string curr;
 
for (int i = 0; i < str.size(); i++) {
            curr.push_back(str[i]);
            dfs(digits, index + 1, m, curr, result);
            curr.pop_back();
        }

@summer2788 summer2788 self-assigned this Jul 20, 2024
@summer2788 summer2788 linked an issue Jul 20, 2024 that may be closed by this pull request
Copy link

우측에 있는 Projects, Milestone, Development를 확인 후 할당 해주세요~! 🙇

Copy link
Member

@jihostudy jihostudy left a comment

Choose a reason for hiding this comment

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

"이미 생각했던 솔루션이지만 당연히 안될 줄 알고 건너뛴 것이다. 너무 time complexity 에 얽매이지 않고 더 나은 solution 이 도저히 생각안나면 최선의 solution 으로 돌려봐야겠다."

이 말이 진짜 맞는게 실전에서는 기본 테케라도 맞추면 점수가 있어서 일단 풀고 생각하는게 좋은듯

대게로 시간복잡도 문제는 쉬운 케이스는 금방 구현이되기도함.

나이스여~🤔

Copy link
Collaborator

@kinwjdghks kinwjdghks left a comment

Choose a reason for hiding this comment

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

때론 최적화에 너무 신경쓰지 않는게 더 좋은 방법일 때가 있죠~

@summer2788 summer2788 merged commit d36e3a4 into main Jul 22, 2024
4 checks passed
@summer2788 summer2788 deleted the 20일차_Jongeun branch July 22, 2024 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[DAILY] 20일차
3 participants