Skip to content

A set of source codes to solve algorithm written in python

Notifications You must be signed in to change notification settings

hojongs/algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

81 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Algorithms

Impressive problems

DP

Leetcode

https://leetcode.com/problemset/all/

my account

Baekjoon Online Judge

https://www.acmicpc.net/problemset

my account

Python tips

Python์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ๋А๋ฆฌ๋‹ค. ์ด๋กœ ์ธํ•œ ์‹œ๊ฐ„ ์ดˆ๊ณผ๋ฅผ ํ”ผํ•˜๊ธฐ ์œ„ํ•ด, Python๋ณด๋‹ค๋Š” PyPy๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ œ์ถœํ•˜๊ธฐ๋ฅผ ๊ถŒ์žฅํ•œ๋‹ค.

๋ฐฑ์ค€ ์‚ฌ์ดํŠธ๋Š” IO๋„ ์ฝ”๋“œ์—์„œ ์ง์ ‘ ์ฒ˜๋ฆฌํ•œ๋‹ค ์ข…์ข… IO ์ฝ”๋“œ๊ฐ€ ์‹œ๊ฐ„ ์ดˆ๊ณผ์˜ ์›์ธ์ด ๋œ๋‹ค

https://www.acmicpc.net/problem/15552

https://www.acmicpc.net/board/view/22716

https://www.acmicpc.net/blog/view/55

https://www.acmicpc.net/blog/view/70

https://wiki.python.org/moin/TimeComplexity

  • input
    • sys.stdin.readline() ์‚ฌ์šฉํ•˜๊ธฐ : input() ์ง€์–‘
      • ๋‹จ, readline()์€ \n์„ ํฌํ•จํ•˜๋ฏ€๋กœ, ์ด๋ฅผ ์ œ์™ธํ•˜๋ ค๋ฉด rstrip()์„ ํ•จ๊ป˜ ์‚ฌ์šฉํ•œ๋‹ค
    • * operator๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ list ์ดˆ๊ธฐํ™”ํ•˜๊ธฐ reference
      • ์ˆ˜ํ–‰ ์‹œ๊ฐ„ 2์ดˆ ์ด์ƒ์—์„œ๋Š” ์˜ํ–ฅ์ด ์—†์—ˆ๋‹ค
    import sys
    
    n = int(sys.stdin.readline())
    strs = [0] * n
    for i in range(n):
        strs[i] = sys.stdin.readline().rstrip()
  • print() ํ•œ ๋ฒˆ๋งŒ ํ˜ธ์ถœํ•˜๊ธฐ : print
    • ๋ผ๊ณ  ์ผ์œผ๋‚˜, 15552 ์—์„œ๋Š” ์˜คํžˆ๋ ค ์‹œ๊ฐ„ ์ดˆ๊ณผ?๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค
    output = ''
    for s in strs:
      output += s + '\n'
    print(output)
  • queue ์šฉ๋„๋กœ list ๋Œ€์‹  collections.dequeue ์‚ฌ์šฉํ•˜๊ธฐ reference
  • Pypy: print()๋ณด๋‹ค sys.stdout.write() ์‚ฌ์šฉํ•˜์—ฌ ๋ฉ”๋ชจ๋ฆฌ ์ ˆ์•ฝํ•˜๊ธฐ reference
  • Pypy๋Š” ์žฌ๊ท€์— ์•ฝํ•˜๋‹ค? reference

Programmers

https://programmers.co.kr/

About

A set of source codes to solve algorithm written in python

Topics

Resources

Stars

Watchers

Forks