PROGRAMMING

PROGRAMMING/Algorithm

[프로그래머스] 순위 검색 (python)

https://programmers.co.kr/learn/courses/30/lessons/72412 총 2**4 = 16개의 조건에 만족될 수 있다. 이 때, 만들어진 쿼리에 X 점수의 지원자가 한명 존재한다는 의미로 쿼리에 해당 지원자의 점수를 저장한다. 따라서 지원자는 총 16가지 key에 점수가 저장된다. (key 구성은 조건을 구별할 수 있도록 구성하면 된다.) -> ex. combination_dict["java backend junior pizza"] = [150] 그리고 쿼리가 들어오면, combination_dict에서 쿼리에 해당하는 조건을 찾아서 점수를 만족하면 count 해주면 된다. from collections import defaultdict def solution(info, ..

PROGRAMMING/Algorithm

[LeetCode] 38. Count and Say (python)

https://leetcode.com/problems/count-and-say/ Count and Say - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 📍 Problem count-and-say sequence는 재귀적으로 정의된 숫자 문자열로, - countAndSay(1) = '1' 로 시작해서, - countAndSay(n) 은 countAndSay(n-1) 를 읽은 문자열을 숫자로 표현한다. 예를 들어 Input n=2 인 경우, countAndSay..

PROGRAMMING/Python

[Python] timestamp, datetime, str 변환하기

서버 작업 시, time 관련 변환 작업이 빈번하다. 빠른 timestamp datetime str 간 변환을 위해 변환 과정을 정리하였다. Timestamp 생성 import time ts = time.time() #1617609622.703449 Timestamp to Datetime import time from datetime import datetime now = time.time() # create timestamp #1617610012.0 dt = datetime.fromtimestamp(now) #datetime.datetime(2021, 4, 5, 17, 9, 0, 460754) Datetime to String date timestamp -> datetime -> str import t..

PROGRAMMING/C++

[STL] c++ std::string, complex, bitset, pair 기초 문법

std::string STL string을 이용한 문자열 처리 c header를 사용할 때의 strcpy(), strcmp() 의 함수를 사용할 필요 없이, 일반 변수와 같이 유사하게 코드를 작성할 수 있다. #define _CRT_SECURE_NO_WARNINGS #include #include //c header #include //STL string, strcpy(), strcmp()등 사용할 필요없이 일반 변수와 유사하게 작성 using namespace std; int main() { string s1 = "hello"; char s2[10]; strcpy(s2, s1.c_str()); //c_str() const char* 로의 반환, 반환된 문자열을 널 문자로 끝나는 문자열 string s3..

KIM DEON
'PROGRAMMING' 카테고리의 글 목록 (2 Page)