본문 바로가기

전체 글400

구명보트 첫번째 코드 순서대로 정렬한 후에 index1 = 처음부터 시작하는 indexindex2 = 마지막부터 시작하는 index그렇게 index1의 값과 index2의 값을 더해 limit보다 크면 index1은 그대로 누고 index2 -= 1이면서 answer += 1 index1의 값과 index2의 값을 더해 limit보다 작으면 index1 += 1, index2 -= 1를 적용한다. 이는 최대 2명까지만 보트에 탑승이 가능하기 때문에 가능한 것이다. def solution(people, limit):     answer = 0          people.sort()     index1 = 0     index2 = len(people) - 1          while index1         .. 2024. 6. 15.
Titanic - Machine Learning from Disaster 파일 정리(데이터 파일)- data- preprocessed_data- result(코드 파일)- preprocessing_code-modeling_code 0. directory 확인1. load data데이터 불러오기2. data preprocessing2-1. data check - 각 변수 의미 확인VariableDefinitionKeysurvivalSurvival 0 = No1 = YespclassTicket classA proxy for socio-economic status (SES)1 = 1st2 = 2nd3 = 3rdsexSex AgeAge in yearsAge is fractional if less than 1. If the age is estimated, is it in the for.. 2024. 6. 15.
Range Sum of BST 첫번째 코드 사실 트리에 대해서는 이해하지만 트리를 만드는 코드와 해당 트리를 다루는 방법을 몰라서 GPT를 참고했다.이렇게 코드를 작성해도 아직 확실한 이해는 잘 모르겠다...어떻게 트리를 짜야하는지.... 다뤄야 하는지.... # Definition for a binary tree node. class TreeNode:     def __init__(self, val=0, left=None, right=None):         self.val = val         self.left = left         self.right = right class Solution:     def rangeSumBST(self, root: Optional[TreeNode], low: int, high: int.. 2024. 6. 14.
Moose Kills Alaska Man Attempting to Take Photos of Her Calves Moose Kills Alaska Man Attempting to Take Photos of Her CalvesBY MARK THIESSEN / APMAY 20, 2024 8:38 PM EDT야생의 모든 동물들이 새끼를 낳았을 때 가장 예민하다고 한다....고인의 명복을 빈다.... 자주 일어나지 않는 일이어도, 특정 나라에 특정 동물들이 많이 산다면 해당 동물들의 대한 특징이나 대피법 관련된 교육이 필요할 것이다. 사진의 무스는 참 귀엽게 생겼는데 말이다....ㅎㅎ; 생긴 것과 공격성은 다르니까! 호주의 캥거루 대처법이나....시골의 멧돼지 대처법?moose calves 무스 송아지authorities 당국 brush 스치다 witness 목격하다stomping 밟다 harassing 괴롭히다agita.. 2024. 6. 14.
043 최대공약수 첫번째 코드 유클리드 호제법은 최대공약수를 구하는 방법으로  이를 이용하여 쉽게 풀었다.하지만 sort가 되어 있지 않아 이 부분만 신경써주면 된다.1로 출력해야 하므로 방법만 알고 있으면 금방이다. import sys input = sys.stdin.readline def MOD(x, y):     a = max(x, y)     b = min(x , y)     if b == 0:         return a     else:         return MOD(b, a % b) n, m = map(int, input().split()) answer = MOD(n, m) while answer > 0:     print(1, end = '')     answer -= 1 통과:)링크https://gi.. 2024. 6. 13.
Search Insert Position 첫번째 코드 단순하게 직접 찾으면서 비교하면 된다라고 생각했다. class Solution:    def searchInsert(self, nums: List[int], target: int) -> int:        count = 0        for i in nums:            if i                 count += 1            elif i == target:                return count            elif i > target:                return count 시간초과두번째 코드 시간 초과가 문제가 되므로 찾는 것을 더 적게 해야한다.이때 이진탐색을 이용하면 탐색에 더 적은 시간이 걸린다. class Solutio.. 2024. 6. 13.
728x90