전체 글 300

[Python] 문자열 숫자인지 판별

LeetCode 문제 풀이 중 문자열로 구성된 배열(List)에서 꺼낸 문자열이 숫자인지 여부를 판별하기 위해 고민하던 중 찾아봤다. 1. 아스키 코드(ASCII) : 가장 떠오른 방법이다. 이 방법은 0부터 9까지, 즉 한 자리 숫자만 판별이 가능하다는 한계가 있다. 숫자를 따옴표 안에 넣어 직관적으로 조건문을 선언해도 되고 각각 숫자 0과 9의 아스키 코드 값인 48과 57로 선언해도 된다. 아래는 임의의 문자열 변수(string)를 통한 예다. if "0"

[Python] subscriptable: TypeError

파이썬 코드를 작성하던 중 아래와 같은 에러가 발생했다. : TypeError: 'int' object is not subscriptable 위 에러는 배열에 존재하지 하지 않는 구역에 접근하려고 할 때 발생하며, 예시는 아래와같다. arr = [1, 2, [3, 4]] print(arr[0][1]) 실행 결과: TypeError Traceback (most recent call last) in 1 arr = [1, 2, [3, 4]] ----> 2 print(arr[0][1]) TypeError: 'int' object is not subscriptable * subscript: 아래에 기입한, 아래와 적은 문자[숫자, 기호] 참고 - https://en.dict.naver.com/#/entry/enk..

[LeetCode] 359. Logger Rate Limiter

난이도는 Easy로 아래와 같다. Design a logger system that receives a stream of messages along with their timestamps. Each unique message should only be printed at most every 10 seconds (i.e. a message printed at timestamp t will prevent other identical messages from being printed until timestamp t + 10). All messages will come in chronological order. Several messages may arrive at the same timestamp. Imple..

[Java] Queue(큐) 선언 및 사용

Queue는 대표적인 자료구조(Data Structure)로 일반적으로 First In First Out(FIFO)로 동작한다. (대조되는 자료구조로는 Stack이 있고 Stack은 일반적으로 First In Last Out(FILO)). 담고자 하는 자료형에 따라 Integer, String과 같은 자료형을 함께 선언하면 된다. Java에서 Queue 선언 및 사용은 아래와 같다. import java.util.Queue; import java.util.LinkedList; public class Main { public static void main(String[] args) { Queue iQ = new LinkedList(); Queue sQ = new LinkedList(); iQ.offer(1..

[Python] deque(데크)

GeeksforGeeks에 따르면 Deque에 대한 설명은 아래와 같다. :Deque (Doubly Ended Queue) in Python is implemented using the module “collections“. Deque is preferred over a list in the cases where we need quicker append and pop operations from both the ends of the container, as deque provides an O(1) time complexity for append and pop operations as compared to a list that provides O(n) time complexity. : "colletions..

[Tech, etc.] Lowest Common Ancestor(LCA, 최소 공통 조상)

GeeksforGeeks에 따르면 Lowest Common Ancestor(LCA)의 정의는 아래와 같다. : The lowest common ancestor is the lowest node in the tree that has both n1 and n2 as descendants, where n1 and n2 are the nodes for which we wish to find the LCA. Hence, the LCA of a binary tree with nodes n1 and n2 is the shared ancestor of n1 and n2 that is located farthest from the root. : LCA는 트리에서 n1과 n2를 자손(descendants)으로 가지는 가장..

[Tech, etc.] 파라미터(Parameter) vs 아규먼트(Argument)

1. 파라미터(매개변수) : 함수(메소드)를 정의할 때 함수명 우측에 추가되는 변수 2. 아규먼트(인자) : 함수(메소드)를 호출할 때 우측에 입력되는 변수 또는 값 3. 예시 : 아래 예시에서 main 함수 내에서 sum() 호출 시 입력된 1, 2는 아규먼트. sum()을 정의할 때 선언된 n1, n2는 파라미터. public static void main(String[] args) { int tot = sum(1, 2); // 1, 2는 아규먼트 System.out.println(tot); } public static int sum(int n1, int n2){ // n1, n2는 파라미터 return n1 + n2; } 실행 결과: 3 출처 1. https://dev-note-97.tistory...

기술(Tech, IT) 2022.09.20

[Tech, etc.] 블랙 박스 테스트(Black box test) vs 화이트 박스 테스트(White box test)

1. 블랙 박스 테스트(외부) : 내부 구조를 참고하지 않고 AUT(Application Under Test)를 테스트 하는 것으로 응용 프로그램(어플리케이션)을 시각화하여 수행한다. 시스템의 내부 구조는 고려하지 않고 응용 프로그램의 기능을 기반으로 테스트 케이스를 도출해 진행한다. - 실행 파일 형태로 테스트 - 의도된 대로 동작하는지 테스트 - 기술적인 지식 불필요 - 화이트 박스 테스트보다 많은 비용 - 내부에 적용된 보안 기술 알 수 없음 - 종류: 동치 분할 검사(Equivalence Partitioning), 경계값 분석(Boundary Value Analysis), 원인-결과 그래프 검사(Cause Effect Graph), 비교 검사, 오류 예측 검사(Error Guessing), 의사 ..