본문 바로가기

분류 전체보기174

[Python 기초] 정렬 (sort) #알파벳, 숫자 크기 순으로 정렬 L=['abcd','xyz','spam'] sorted(L) #Out: ['abcd', 'spam', 'xyz'] L=[3,7,2,7,1,7] L.sort() L #Out: [1, 2, 3, 7, 7, 7] #lambda : 익명함수 (lambda x,y: x + y)(5, 6) #Out: 11 ▼ 익명 함수 lambda 활용법 더보기 더보기 #map() list(map(lambda x: x ** 2, range(5))) # 파이썬 2 및 파이썬 3 #Out: [0, 1, 4, 9, 16] #reduce() from functools import reduce reduce(lambda x, y: x + y, [0, 1, 2, 3, 4]) #Out: 10 reduce(lam.. 2020. 9. 5.
LeetCode 101. Symmetric Tree - Python LeetCode 101. Symmetric Tree - Python Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the following [1,2,2,null,3,null,3] is not: 1 / \ 2 2 \ \ 3 3 Solution : Recursive class Solution: def isSymmetric(self, root: TreeNode) -> bool: if not root: #루트가 없으면 True 반환.. 2020. 9. 4.
LeetCode 1. Two Sum - Python LeetCode 1. Two Sum - Python Given an array of integers nums and and integer target, return the indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[.. 2020. 8. 31.
LeetCode 543. Diameter of Binary Tree - Python LeetCode 543. Diameter of Binary Tree - Python Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. 이진트리의 지름 구하기 즉 가장 긴 path의 '길이'를 구하면 된다. 이 때, 노드 사이의 길이란 노드 사이의 edge의 개수이다. 예를 들어 아래의 경우 path [4,2,1,3] 나 [5,2,1,3]가 가장 길기 때문에.. 2020. 8. 25.
LeetCode 121. Best Time to Buy and Sell Stock - Python Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. Note that you cannot sell a stock before you buy one. Example 1: Input: [7,1,5,3,6,4] Output: 5 Explanation: Buy on day 2 (price = 1) and sell on day .. 2020. 8. 24.
[ADsP] 데이터마트 1. 데이터 이해 1-1. 데이터의 이해 1-2. 데이터의 가치와 미래 1-3. 가치 창조를 위한 데이터 사이언스와 전략 인사이트 2. 데이터 분석 기획 2-1. 데이터 분석 기획의 이해 2-2. 분석 마스터 플랜 3. 데이터 분석 3-1. R 기초와 데이터 마트 3-1-1. R 프로그래밍 기초 3-1-2. 데이터마트 3-2. 통계분석 3-3. 정형 데이터 마이닝 데이터마트 #데이터 변경 및 요약 (1) 데이터 마트(Data Mart) - 데이터 웨어하우스(DW)와 사용자 사이의 중간층에 위치한 것으로, 하나의 주제 또는 하나의 부서 중심의 데이터 웨어하우스라고 할 수 있다. - 데이터 마트 내 대부분의 데이터는 DW로부터 복제되지만, 자체적으로 수집될 수도 있으며, 관계형 DB나 다차원 DB를 이용하여.. 2020. 8. 23.
[ADsP] R 프로그래밍 기초 1. 데이터 이해 1-1. 데이터의 이해 1-2. 데이터의 가치와 미래 1-3. 가치 창조를 위한 데이터 사이언스와 전략 인사이트 2. 데이터 분석 기획 2-1. 데이터 분석 기획의 이해 2-2. 분석 마스터 플랜 3. 데이터 분석 3-1. R 기초와 데이터 마트 3-1-1. R 프로그래밍 기초 3-1-2. 데이터마트 3-2. 통계분석 3-3. 정형 데이터 마이닝 R 프로그래밍 기초 #R 소개 (1) R 소개 - R은 오픈소스 프로그램으로 통계, 데이터마이닝을 위한 언어이다. - 윈도우, 맥, 리눅스 OS에서 사용 가능하다. - 객체 지향 언어이며 함수형 언어이다. 즉, 통계 기능뿐만 아니라 일반 프로그래밍 언어처럼 자동화하거나 새로운 함수를 생성하여 사용 가능 - 객체 지향 언어는 필요한 부분을 프로그.. 2020. 8. 23.
[ADsP] 주성분 분석 1. 데이터 이해 1-1. 데이터의 이해 1-2. 데이터의 가치와 미래 1-3. 가치 창조를 위한 데이터 사이언스와 전략 인사이트 2. 데이터 분석 기획 2-1. 데이터 분석 기획의 이해 2-2. 분석 마스터 플랜 3. 데이터 분석 3-1. R 기초와 데이터 마트 3-2. 통계분석 3-2-1. 통계학 개론 3-2-2. 기초 통계분석 3-2-3. 다변량 분석 3-2-4. 시계열 에측 3-2-5. 다차원 척도법 3-2-6. 주성분 분석 3-3. 정형 데이터 마이닝 #주성분분석의 정의 - 여러 변수들의 변향을 주성분이라는 서로 상관성이 높은 변수들의 선형결합으로 만들어 기존의 상관성이 높은 변수들을 요약, 축소하는 기법이다. - 첫 번째 주성분으로 전체 변도을 가장 많이 설명할 수 있도록하고, 두 번째 주성분.. 2020. 8. 22.
[ADsP] 다차원 척도법 1. 데이터 이해 1-1. 데이터의 이해 1-2. 데이터의 가치와 미래 1-3. 가치 창조를 위한 데이터 사이언스와 전략 인사이트 2. 데이터 분석 기획 2-1. 데이터 분석 기획의 이해 2-2. 분석 마스터 플랜 3. 데이터 분석 3-1. R 기초와 데이터 마트 3-2. 통계분석 3-2-1. 통계학 개론 3-2-2. 기초 통계분석 3-2-3. 다변량 분석 3-2-4. 시계열 에측 3-2-5. 다차원 척도법 다차원 척도법 #다차원척도법 정의 - 객체간 근접성을 시각화하는 통계기법이다. - 군집분석과 같이 개체들을 대상으로 변수들을 측정한 후에 개체들 사이의 유사성/비유사성을 측정하여 개체들을 2차원 공간상에 점으로 표현하는 분석방법이다. - 개체들 2차원 또는 3차원 공간 상에 점으로 표현하여 개체들 사.. 2020. 8. 22.
LeetCode 21. Merge Two Sorted Lists - Python LeetCode 21. Merge Two Sorted Lists - Python 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: Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4 Solution : class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: if l1 is None : return l2 if l2 is None : return l1 if.. 2020. 8. 21.