본문 바로가기

코딩테스트20

[leetcode/JS] 234. Palindrome Linked List / Javascript 문제링크 https://leetcode.com/problems/palindrome-linked-list/ Palindrome Linked List - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 기억하면 좋을 것 배열의 순서를 정반대로 뒤바꾸고 싶을때 어떻게 할까 ? 바로 reverse 배열 내장 함수를 사용하면 된다. 그런데 문자열을 정반대로 바꾸어 주고 싶다면 ? split() reverse() join() 세가지를 기억하자 split('') 은 문자열을 .. 2022. 8. 25.
[leetcode/JS] 70. Climbing Stairs / Javascript 문제링크 https://leetcode.com/problems/climbing-stairs/ Climbing Stairs - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 기억하면 좋을 것 이 문제는 recursive로 풀면 시간 초과로 통과하지 못한다. memoization 을 이용해 빈 배열을 생성하고 , 거기에 결과값을 저장 해 나가며 최종 결과를 반환해야한다. DP는 하향식(Top-Down 방식), 상향식(Bottom-UP 방식) 두 가지 방식으로 풀 수.. 2022. 8. 23.
[leetcode/JS] 617. Merge Two BInary Trees / Javascript 문제링크 https://leetcode.com/problems/merge-two-binary-trees/ Merge Two Binary Trees - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 기억하면 좋을 것 / 소감 아직 재귀를 사용하는게 미숙하다. 재귀를 사용할 때 1. 어떻게 반복 할 것인지 2. 어떤 조건에서 return, 종료 해 줄것인지 가 핵심임을 기억하자 지금은 실력이 부족하니 어떻게 해야 효율적으로 풀지 생각하기보다 일단 푸는것을 목적으로 .. 2022. 5. 12.
[프로그래머스]정렬 | K번째 수 JS 풀이 K번째 수 문제 링크 https://programmers.co.kr/learn/courses/30/lessons/42748 코딩테스트 연습 - K번째수 [1, 5, 2, 6, 3, 7, 4] [[2, 5, 3], [4, 4, 1], [1, 7, 3]] [5, 6, 3] programmers.co.kr 생각 해 볼만한 점 / 2번째 케이스 체점 오류 문제 자체는 쉽고, 간단하게 풀 수 있다. 그런데 2번째 케이스에서 체점 오류가 나면서 그냥 정렬 하기 위해 쉽게 생각 없이 써 왔던 sort() 에 대해 생각 해 보게 되었다. sort() 메서드는 배열의 요소를 적절한 위치에 정렬한 후 그 배열을 반환합니다. 정렬은 stable sort가 아닐 수 있습니다. 기본 정렬 순서는 문자열의 유니코드 코드 포인트를.. 2022. 4. 24.