전체 글
-
[Python] tensorflow.expand_dimsImplementation/Python 2021. 9. 28. 13:41
import numpy as np import random import tensorflow as tf sp = np.random.randint(-90, 100, (2,6)) # >>> sp # array([[ 8, -67, 34, -71, -50, -69], # [ 56, 30, 58, 76, 1, -83]]) tf.expand_dims( sp, axis=0 ) # tf.expand_dims( sp, axis=1 ) # tf.expand_dims( sp, axis=2) # # axis = 0 or 1 or 2 일 때 # axis = 0, (expanded, row, col) # axis = 1, (row, expanded, col) # axis = 2, (row, col, expanded) # 바뀐 sh..
-
[Python] unique key counting dictionaryImplementation/Python 2021. 9. 26. 21:29
# 리스트 요소의 unique key value count 를 dict 구조로 만들어주는 라이브러리 from collections import Counter s2 = "dcda" Counter(s2) #Counter({'d': 2, 'c': 1, 'a': 1}) # 리스트 컴프리헨션으로 만들면 아래와 같다 dict(zip(s2, [s2.count(k) for k in s2])) #{'d': 2, 'c': 1, 'a': 1}
-
[LeetCode]567. Permutation in StringAlgorithm/LeetCode 2021. 9. 26. 21:16
Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. In other words, return true if one of s1's permutations is the substring of s2. Example 1: Input: s1 = "ab", s2 = "eidbaooo" Output: true Explanation: s2 contains one permutation of s1 ("ba"). Example 2: Input: s1 = "ab", s2 = "eidboaoo" Output: false Constraints: 1 bool: flag = False len_s1 = len(s1..