본문 바로가기

프로그래밍14

[Leetcode/Python] 328. Odd Even Linked List 문제 링크 Odd Even 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 문제 설명 단일 연결 리스트의 헤드가 주어지면 홀수 인덱스를 가진 모든 노드와 짝수 인덱스를 가진 노드를 함께 그룹화하고 재정렬된 리스트를 반환합니다. 첫 번째 노드는 홀수로 간주되고 두 번째 노드는 짝수로 간주됩니다. 짝수 그룹과 홀수 그룹 내부의 상대적인 순서는 입력에서 그대로 유지되어야 합니다. O(1) 공간 복잡도 및 O(n) 시간 복잡도에서 문제를 해결해야.. 2022. 12. 6.
[Leetcode/Python] 380. Insert Delete GetRandom O(1) 문제 링크 Insert Delete GetRandom O(1) - 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 문제 설명 RandomizedSet 클래스를 구현합니다. - RandomizedSet() RandomizedSet 개체를 초기화합니다. - bool insert(int val) 항목 val이 없으면 집합에 삽입합니다. 항목이 없으면 true를 반환하고 그렇지 않으면 false를 반환합니다. - bool remove(int val) 항목 val이 있는 .. 2022. 11. 29.
[Leetcode/Python] 79. Word Search 문제 링크 Word Search - 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 문제 설명 m x n의 문자칸과 단어가 주어지고, 단어가 문자칸에 있으면 true를 반환합니다. 단어는 연속적으로 인접한 셀의 문자로 구성될 수 있으며 인접한 셀은 가로 또는 세로로 이웃합니다. 동일한 문자 셀은 두 번 이상 사용할 수 없습니다. 그림과 같이 문자칸내에서 연속해서 연결했을때, 단어가 존재하면 true, 아닐경우 false를 반환하면 된다. 2차원 배열을 써야 하는 .. 2022. 11. 25.
[Leetcode/Python] 263. Ugly Number 문제 링크 Ugly Number - 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 문제 설명 Ugly Number는 소인수가 2, 3, 5로 제한되는 양의 정수입니다. 정수 n이 주어지면 n이 Ugly Number면 true를 반환합니다. 입출력 예시 입력 출력 6 true 1 true 14 false 제한 사항 -2^31 1: return False return True 코딩 테스트, 어떻게 대비해야 할까? 개발 관련 분야로 취업을 하려면 서류통과 이후 코딩 .. 2022. 11. 18.
[Leetcode/Python] 223. Rectangle Area 문제 링크 Rectangle Area - 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 문제 설명 2D 평면에서 두 직선 사각형의 좌표가 주어지면 두 사각형이 차지하는 총 면적을 반환합니다. 첫 번째 사각형은 왼쪽 아래 모서리(ax1, ay1)와 오른쪽 위 모서리(ax2, ay2)로 정의됩니다. 두 번째 사각형은 왼쪽 아래 모서리(bx1, by1)와 오른쪽 위 모서리(bx2, by2)로 정의됩니다. 간단히 이런 식으로 도형이 그려지고 색칠된 부분의 넓이를 구하면.. 2022. 11. 17.
[Leetcode/Python] 222. Count Complete Tree Nodes 문제 링크 Count Complete Tree Nodes - 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 문제 설명 완전 이진 트리의 root가 주어지면 트리의 노드 수를 반환합니다. Wikipedia에 따르면 마지막 레벨을 제외한 모든 레벨은 완전한 이진 트리로 완전히 채워져 있으며 마지막 레벨의 모든 노드는 가능한 한 가장 왼쪽에 있습니다. 마지막 레벨 h에서 포함하여 1~2^h 노드를 가질 수 있습니다. O(n) 시간 복잡도 미만으로 실행되는 알고리즘을 .. 2022. 11. 15.