archives

  • 홈
  • 태그
  • 미디어로그
  • 위치로그
  • 방명록

2022/01 2

leetcode 1763(브루트포스), 1099(two pointer), 395(구현), 1071(구현)

1763 https://leetcode.com/problems/longest-nice-substring/ easy 로 분류되었는데 medium 하위정도 되는것같다. O(n^2)으로 모든 경우를 탐색한다. 길게 좌우에서 조여오면서 탐색한다. cur_s는 l과 r이 움직임에 따라 만들어지는 부분적인 문자열이고, cur_s내의 모든 문자가 대문자와 소문자가 cur_s내에 존재해야 하면서 이게 이전 길이보다 더 길면 바꿔준다. class Solution: def longestNiceSubstring(self, s: str) -> str: len_s = len(s) l = 0 ret = '' while l < len_s: r = len_s - 1 while l < r: cur_s = s[l:r+1] if all(..

algorithm/problem solving 2022.01.23

leetcode 974(prefix sum), 1375(구현;), 93(백트래킹), 616(merge interval)

974 https://leetcode.com/problems/subarray-sums-divisible-by-k/ subarray의 합이 k로 나눠지는 subarray를 구해야하는데 인덱스와 상관없이 구하는게 아니라 근처의 값들로만 구성해야 해서 백트래킹같은게 아니다. 앞에서부터 prefix sum을 계산해주며 prefix sum이 k로 나눠지면 그 값이 존재하는만큼 더해준다. 그리고 뒤에서도 사용하기 위해 그 값이 나온만큼 증가시켜준다. class Solution: def subarraysDivByK(self, nums: List[int], k: int) -> int: ret = 0 d = {0: 1} prefix_sum = 0 for i in range(len(nums)): prefix_sum += ..

algorithm/problem solving 2022.01.03
1
더보기
프로필사진

프로그래밍 좋아합니다. 자료 퍼가실때는 참조만 적어주세요..

  • study (975)
    • setting, git, shell etc (21)
    • machine learning, image (27)
    • data engineering (94)
    • Python (140)
      • 2.7 information (74)
      • 2.7 simple coding(+ c++) (42)
      • 2.7 for fun. (24)
    • web (27)
      • back + front (22)
      • etc (5)
      • kotlin (0)
    • algorithm (210)
      • theory (51)
      • problem solving (159)
    • webhacking (180)
      • sql, sql injection (98)
      • client (28)
      • etc (54)
    • systemhacking (34)
      • practice (25)
      • background (9)
    • private (241)
      • 면접 (0)
      • memo (56)
      • Vancouver diary (77)
      • business trip (10)
      • normal diary (81)
      • English (17)

Tag

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2022/01   »
일 월 화 수 목 금 토
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

  • Hide
  • 지훈현서님 (python developer)
  • 백준 온라인 저지 블로그.(매우 유용)

티스토리툴바