[Python-Leetcode] 4. Median of Two Sorted Arrays (difficulty : Hard - ☆☆☆)
문제 설명 Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2. Example 2: Input: nums1 = [1,2], nums2 = [3,4] Output: 2.50000 Explanation: merged array = [1,2,3,4] and med..
2022. 4. 27.
[Python-Study Leetcode 문제풀이] 665. Non-decreasing Array
Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element. We define an array is non-decreasing if nums[i] [4, 2, 1]의 경우, 2개 이상의 수를 변경해야 하므로, Fail [Solution Code] [1, 2, 3, 4, 5, 6, 4] 라는 배열이 있다고 가정하자 그러면, 각 숫자의 차이값을 계산한다면 [1, 2, 3, 4, 5, 6, 5] ↓ [1, 1, 1, 1, 1, -1] 이라는 배열을 얻을 수 있다. 1) 이때, 모든 배열의 값이 0보다 크거나 같다면, 해당 배열은 모두 증가하는 추세이..
2021. 3. 17.