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

[환미니니] Week4 문제풀이 #425

Merged
merged 6 commits into from
Sep 8, 2024
Merged

Conversation

JEONGHWANMIN
Copy link
Contributor

@JEONGHWANMIN JEONGHWANMIN commented Sep 4, 2024

답안 제출 문제

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@JEONGHWANMIN JEONGHWANMIN added the js label Sep 4, 2024
@JEONGHWANMIN JEONGHWANMIN self-assigned this Sep 4, 2024
@JEONGHWANMIN JEONGHWANMIN requested a review from a team as a code owner September 4, 2024 14:37
@JEONGHWANMIN JEONGHWANMIN marked this pull request as draft September 4, 2024 14:37
nums.sort((a,b) => a - b);

for (let i = 0 ; i <= nums.length; i++) {
if (i !== nums[i]) return i
Copy link
Contributor

Choose a reason for hiding this comment

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

숫자가 0부터 시작하니까 이렇게 비교해서 풀어도 좋겠네요! 배워갑니다 :)

* @param {number[]} nums
* @return {number}
*/
var missingNumber = function(nums) {
Copy link
Contributor

Choose a reason for hiding this comment

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

js에서 sort는 내부적으로 추가적인 메모리를 사용해서 공간복잡도가 O(1)은 아닐 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

엇 그렇네요 정렬할 때 공간복잡도가 On 사용됩니다!
감사합니다 : )


while (leftIdx <= rightIdx) {
if (strs[leftIdx] !== strs[rightIdx]) return false

Copy link
Contributor

Choose a reason for hiding this comment

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

오 양쪽에서 인덱스를 증가시키거나 감소시키면서 하나씩 비교하니 풀이가 굉장히 깔끔하네요!

let maxSequenceLength = -Infinity


const setNums = [...new Set(nums)].toSorted((a,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.

엇 그런데 문제 조건에서 O(n)에 동작하는 코드를 작성해야 한다고 했는데, 해당 코드는 시간복잡도가 nlogn이 되는 것 같습니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

앗 그냥 생각나는데로 풀어버렸네요 ㅜ
정렬을 안쓰고 풀어봐야겠어요 ~

@JEONGHWANMIN JEONGHWANMIN marked this pull request as ready for review September 7, 2024 14:57
Copy link
Contributor

@DaleSeo DaleSeo left a comment

Choose a reason for hiding this comment

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

정렬을 잘 쓰시네여요. 수고하셨습니다!

// m은 board의 행 수, n은 board의 열 수, 4(상하좌우), l(word)

// 시간복잡도: O(m * n * 4L)
// 공간복잡도: O(m * n + L)
Copy link
Contributor

Choose a reason for hiding this comment

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

@JEONGHWANMIN JEONGHWANMIN merged commit ec1875b into DaleStudy:main Sep 8, 2024
1 check passed
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.

3 participants