티스토리

ML studying
검색하기

블로그 홈

ML studying

gy-study.tistory.com/m

for dream 님의 블로그입니다.

구독자
1
방명록 방문하기
반응형

주요 글 목록

  • [leetcode] No 18. 4Sum Python Solution [Problem] Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 List[List[int]]: if len(nums) tmp: right -= 1 else: left += 1 ans.sort() result = [] if len(ans) > 0: result.append(ans[0]) for k in range(1, len(ans)): if ans[k] != result[-1]: result.append(ans[k]) return result Well.. I have to find better solution TT 공감수 1 댓글수 0 2023. 6. 6.
  • [leetcode] No 16. 3Sum Closest Python Solution [Problem] Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. [Explanation] This problem's goal is to find the sum of three elements which is closest to target. To solve it, two pointer algorithm is used with fixed po.. 공감수 0 댓글수 1 2023. 5. 30.
  • [leetcode] No 980. Unique Paths III Python Solution [Problem] You are given an m x n integer array grid where grid[i][j] could be: 1 representing the starting square. There is exactly one starting square. 2 representing the ending square. There is exactly one ending square. 0 representing empty squares we can walk over. -1 representing obstacles that we cannot walk over. Return the number of 4-directional walks from the starting square to the end.. 공감수 1 댓글수 0 2023. 5. 29.
  • [leetcode] No 63. Unique Paths II Python Solution [Problem] You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time. An obstacle and space are marked as 1 or 0 respectively in grid. A path that the robot takes cannot include any square th.. 공감수 0 댓글수 0 2023. 5. 28.
  • [Leetcode] No 62. Unique Paths Python Solution [Problem] There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time. Given the two integers m and n, return the number of possible unique paths that the robot can take to reach the bottom-right corner. .. 공감수 0 댓글수 0 2023. 5. 28.
  • [Leetcode] No 4. Median of Two Sorted Arrays Python Solution ⭐️ [Problem] 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)). [Explanation] Well.. this problem can be solve simply if there isn't condition about time complexity... In this problem, to satisfy time complextiy, it need to use binary search. Because some functions and algorithm li.. 공감수 0 댓글수 0 2023. 5. 21.
  • Python pandas basic: crosstap, fillna, isna 1) crosstab - To make frequency tableimport pandas as pd df = pd.read_csv('iris.csv') pd.crosstab(df.loc[:10, 'Sepal.Width'], df.loc[:10, 'Petal.Width'])2) isna() isna() is the same with isnull() In reverse, notna() is the same with notnull() 3) fillna() To handle nan value easily, fillna() is used.Signature: df.fillna(value=None, method=None, axis=None, inplace=False, limit=None, downcast=None,.. 공감수 0 댓글수 0 2023. 5. 7.
  • [leetcode] No 17. Letter Combinations of a Phone Number Python Solution [Problem] Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. [Explanation] Given phone number, I have to find all combinations of string that is contained in each num.. 공감수 0 댓글수 0 2023. 5. 6.
  • [leetcode] No 1. Two Sum Python Solution [Problem] Given an array of integers nums and an integer target, return 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. [Explanation] There are given array and a target value. In the array, two values that can make the target value by add.. 공감수 0 댓글수 0 2023. 5. 6.
  • Python pandas basic: iloc, loc, unique, apply 1) iloc vs loc iloc is to use integer index in dataframe. loc is to use category name in dataframe.import pandas as pd df = pd.read_csv('iris.csv') %To read csv file, use pandas.read_csv df.head(2)df_sub1 = df.loc[:, ['petal.length', 'petal.width', 'variety']] print(df_sub1.head(2)) df_sub2 = df.iloc[:, 2:] print(df_sub2.head(2)) 2) unique It is used to see what categories are included in specif.. 공감수 0 댓글수 0 2023. 5. 3.
  • [leetcode] No 134. Gas Station Python Solution [Problem] There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its next (i + 1)th station. You begin the journey with an empty tank at one of the gas stations. Given two integer arrays gas and cost, return the starting gas station's index if yo.. 공감수 0 댓글수 0 2023. 5. 1.
  • [leetcode] No 56. Merge Intervals Python Solution [Problem] Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. [Explanation] There are given arrays. Some arrays have overlapping intervals with other arrays. In that case, overlapping arrays can represent as one. For example, there are [1, 3] and [2, 6]. T.. 공감수 0 댓글수 0 2023. 5. 1.
  • [leetcode] No 55. jump game Python solution [Problem] You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return true if you can reach the last index, or false otherwise. [Explanation] In this problem, just check possibility whether reaching the last location using previous numbers. [Solution] Sometimes, a simplist.. 공감수 0 댓글수 0 2023. 4. 9.
  • [leetcode] No 75. Sort Colors python3 solution [Problem] Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively. You must solve this problem without using the library's sort function. 빨강색(0), 하얀색(1), 파란색(2)이 랜덤하게 섞여있는 배열을 빨.. 공감수 0 댓글수 0 2023. 4. 2.
  • [leetcode] 45. Jump Game II Python [Problem] You are given a 0-indexed array of integers nums of length n. You are initially positioned at nums[0]. Each element nums[i] represents the maximum length of a forward jump from index i. In other words, if you are at nums[i], you can jump to any nums[i + j] where: 0 idx: break if arr[j][1] + 1 공감수 0 댓글수 0 2023. 3. 5.
  • [leetcode] No 33. Search in Rotated Sorted Array Python [Problem] There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 공감수 0 댓글수 0 2023. 3. 5.
  • [leetcode] No 28. Find the Index of the First Occurrence in a String (python3) [Problem] Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. [Solution] It is quite simple! 1) First, check a length of 'haystack' is shorter than a length of 'needle'. If it is, return -1. 2) Second, before checking all characters between haystack and needle, I checked the last character and the first t.. 공감수 0 댓글수 0 2023. 2. 26.
  • [leetcode] No 15. 3Sum python [Problem] Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, (I thought it was the value of nums[i], but it was just index! Don't get confused. Maybe I am the only one confused?) and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets. [Solution] Actually, I tried several methods. B.. 공감수 0 댓글수 0 2023. 2. 26.
  • [leetcode] No 7. Reverse Integer python [Problem] Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). [Solution] It is quite simple problem. just reverse digits like [123 > -123] In my case, I think int such as string. So, .. 공감수 0 댓글수 0 2023. 2. 25.
  • [leetcode] No 6. Zigzag Conversion Python [Problem] The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) [Explanation] After arranging string to zigzag, combine zigzagged string as one. There is a given number of rows. So I can arrange string in codition of rows and combine as one For example, 'PAYPALISHIRING' and a gi.. 공감수 0 댓글수 0 2023. 2. 20.
  • [CNN] What is Convolutional Neural Network? A Convolutional Neural Network (CNN) is one of Deep Learning algorithms. Why Convolution Layer? not Multi-Layer Perceptron? To use multi-Layer percetron, it need to use fully connected method. It means input features lose their own local information. Then machine learning model will be in trouble to catch the exact information. This leads to poor performance. On the other hands, Convolution Laye.. 공감수 0 댓글수 0 2023. 2. 19.
  • [뉴런과 인공 신경망] What is Artificial Neural Network? Neuron VS Neural Network # What is Artificial Neural Network (ANN) ? 인공 신경망이란 사람의 신경망을 모방하는 학습 알고리즘이다. 인공 신경망을 이해하기 전에 사람의 뉴런 구조와 학습이란 무엇인가를 떠올려봐야 한다. 뉴런의 구조는 아래의 그림과 같다. [Eng. version] Artificial neural network (ANN) is a learning algorithm that mimics neural network of human. Before understanding ANN, it is necessary to think of the structure of humans' neurons and how it is learned. 뉴런은 자극 신호(X)가 입력되는 통로인 수상돌기(Dendri.. 공감수 1 댓글수 0 2023. 2. 19.
  • [LeetCode] No 5. Longest Palindromic Substring https://leetcode.com/problems/longest-palindromic-substring/ Longest Palindromic Substring - LeetCode Longest Palindromic Substring - Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer. Example 2: Input: s = "cbbd" Output: "bb" Constraints: * 1 공감수 0 댓글수 0 2023. 2. 19.
    문의안내
    • 티스토리
    • 로그인
    • 고객센터

    티스토리는 카카오에서 사랑을 담아 만듭니다.

    © Kakao Corp.