본문 바로가기

분류 전체보기91

[Python-Leetcode] 9. Palindrome Number (difficulty : Easy - ☆) 문제 설명 Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 Output: false Explanation: From left to right, it reads -121. From righ.. 2022. 4. 27.
[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.
[sklearn] Data Scaling (Standard / minmax / maxabs / Robust) Data Scaling¶ 학습에 사용될 데이터를 단위 통일화시키는 작업 서로 다른 단위나 값의 크기를 가지는 컬럼별 데이터들의 분포나 단위를 일정하게 통일하는 작업 Standard Scaling Min-Max Scaling Max-Abs Scaling Robust Scailing In [8]: # 1. Standard Scaling # 평균 0, 표준편차 1로 데이터를 변화 (표준정규화) # (X-μ) / σ from IPython.core.display import display, HTML display(HTML("")) from sklearn.preprocessing import StandardScaler import numpy as np import matplotlib.pyplot as plt im.. 2022. 2. 27.
[Python-Leetcode] 232. Implement Queue using Stacks (difficulty : Easy - ☆) 문제 설명 Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty). Implement the MyQueue class: void push(int x) Pushes element x to the back of the queue. int pop() Removes the element from the front of the queue and returns it. int peek() Returns the element at the front of the queue. b.. 2021. 8. 12.
[Python-Leetcode] 739. dailyTemperatures (difficulty : Medium - ☆☆) 문제 설명 Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead. Example 1: Input: temperatures = [73,74,75,71,69,72,76,73] Output: [1,1,4,2,1,1,0,0] Example 2: Input: te.. 2021. 8. 11.
Python - Sorted (정렬, key 2개) 오름차순 / 내림차순 파이썬, Sorted 정렬 (Key 2개) dic1 = {'A':[(0, 1), (5, 1), (5, 3), (9, 2), (6, 2), (6, 1)]} dic1 {'A': [(0, 1), (5, 1), (5, 3), (9, 2), (6, 2), (6, 1)]} dic1['A']를 sorting할 때, 앞의 숫자는 증가하는 방향(오름차순) / 뒤의 숫자는 내림차순하도록 하려면 sorted(dic1['A'], key=lambda x:(x[0], -x[1])) [(0, 1), (5, 3), (5, 1), (6, 2), (6, 1), (9, 2)] sorted에서, key는 어떤 것을 기준으로 sort를 할 것인지를 정하는 것입니다. x[0]은 앞의 숫자를 기준으로 오름차순이며, -x[1]은 뒤의 숫자를 기준.. 2021. 8. 9.