[leetcode 33] Search in Rotated Sorted Array
You are given an integer array nums sorted in ascending order, and an integer target. Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). If target is found in the array return its index, otherwise, return -1. 본래 오름차순인 배열이 특정 위치를 중심으로 회전되어 있다. 주어진 target의 위치를 찾아라. Example 1: Input: nums = [4,5,6,7,0,1,2], target = 0 Output: 4..
2020. 10. 17.
[leetcode 21] Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists. 오름차순순으로 리스트를 합치자. Example 1: Input: l1 = [1,2,4], l2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: l1 = [], l2 = [] Output: [] Example 3: Input: l1 = [], l2 = [0] Output: [0] 풀이: -포인터만 잘 활용한다면 쉬운 문제이다. - 난이도: easy /** * Definition for singly-lin..
2020. 10. 17.