개발공부

    [JavaScript]34. Find First and Last Position of Element in Sorted Array - 쉬운설명

    34. Find First and Last Position of Element in Sorted Array Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4] Example 2: Input: nums = [5,7..

    [JavaScript] 946. Validate Stack Sequences 쉬운설명

    946. Validate Stack Sequences Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty stack, or false otherwise. Example 1: Input: pushed = [1,2,3,4,5], popped = [4,5,3,2,1] Output: true Explanation: We might do the following sequence: push(1), push(2), push(3), push(4), po..

    [JavaScript] 138. Copy List with Random Pointer, 해시맵 사용, 쉬운설명

    [JavaScript] 138. Copy List with Random Pointer, 해시맵 사용, 쉬운설명

    138. Copy List with Random Pointer A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null. n의 길이를 하고있는, 링크리스트가있고, 각 노드는 노말 포인터와, 랜덤 포인터를 가지고있고 이 랜덤 포인터는 리스트에 포함된 아무 노드나 null값을 가르킵니다. Construct a deep copy of the list. The deep copy should consist of exactly n brand new nodes, where each new node has its val..

    [JavaScript] 61. Rotate List Medium  - 연결리스트 노드 옮기기, 쉬운설명, 반복문 사용

    [JavaScript] 61. Rotate List Medium - 연결리스트 노드 옮기기, 쉬운설명, 반복문 사용

    61. Rotate List Given the head of a linked list, rotate the list to the right by k places. Example 1: Input: head = [1,2,3,4,5], k = 2 Output: [4,5,1,2,3] Example 2: Input: head = [0,1,2], k = 4 Output: [2,0,1] 계획 문제 해결 전략 주어진 k만큼 반복하게 됩니다. 하지만 k가 linkedlist의 길이보다 클경우, example 2와 같이 k를 linkedlist length로 나눈 나머지값 만큼만 반복하면되기때문에 반복문에서 k% linkedlistLength의 값만큼 반복하게 합니다. linkedList 특성상 index로 요구하는 위치..