hyunkookim 님의 블로그

  • 홈
  • 태그
  • 방명록

Bit 3

Bit: 191. Number of 1 Bits

191. Number of 1 Bitsclass Solution: def hammingWeight(self, n: int) -> int: cnt = 0 while n: cnt += n & 1 # 제일 오른쪽 비트 0x01 과 and 연산해서 1이면 cnt 1증가: 1 개수 카운팅 n = n >> 1 # n 을 2나누기.해서 업데이트 (오른쪽 쉬프트와 동일) return cntclass Solution: def hammingWeight(self, n: int) -> int: res = 0 while n: # n > 0: res += n % 2 # res += n&1 ..

LeetCode/Grind169 2024.12.17

Bits: 190. Reverse Bits ☆★★

190. Reverse Bits 내 코드class Solution: def reverseBits(self, n: int) -> int: # Reverse bits of a given 32 bits unsigned integer. # 비트 반대로 res = 0 while n: # n 이 0 되면 끝남 res = n & 1 # 제일 오른쪽 비트가 1인지 체크 # n 은 2로 나누어주고 n = n>>1 # res 는 반대로 res = res 당신 코드의 아이디어는 거의 맞습니다만, 2가지 주요 문제가 있어 정답이 안 나옵니다. 아래에 정리해 드릴게요.❗ 문..

LeetCode/Grind169 2024.12.17

Bit: 338. Counting Bits ★★★

338. Counting Bits Given an integer n, return an array ans of length n + 1 such that for each i (0  ans[i] is the number of 1's in the binary representation of i. Example 1:Input: n = 2Output: [0,1,1]Explanation:0 --> 01 --> 12 --> 10Example 2:Input: n = 5Output: [0,1,1,2,1,2]Explanation:0 --> 01 --> 12 --> 103 --> 114 --> 1005 --> 101 Constraints:0  Follow up:It is very easy to come up with a s..

LeetCode/NeetCode 2024.11.09
이전
1
다음
더보기
프로필사진

hyunkookim 님의 블로그

hyunkookim 님의 블로그 입니다.

  • 분류 전체보기 (457)
    • 개인 연구 (0)
    • job 인터뷰 (34)
      • 2025년 1분기 USA (2)
      • 코테(Amazon) 준비 (5)
      • 코테(Matroid) 준비 (27)
      • 코테 문제 (0)
    • 세팅 (7)
      • ubuntu (7)
    • 코드 형상 관리 (2)
      • git (2)
    • Coding Test (72)
      • 알고리즘 이론 (70)
      • Machine Learning (NeetCode) (2)
    • HackerRank (1)
      • 공통 (1)
    • CodeSignal (1)
      • 문제 은행 (1)
    • LeetCode (329)
      • 공통 (7)
      • Grind169 (60)
      • NeetCode (98)
      • Top Interview 150 (68)
      • LeetCode75 (34)
      • DP심화 (38)
      • 주제별 보충 (23)
      • [Weekly Contest] (0)
    • Deep Learning (4)
      • 3D 재구성 (0)
      • 장면 스타일 변환 (2)
      • 물체 인지 & 추적 (0)
      • 렌더링AI (2)
    • 일단 리스트업 (6)
      • 딥러닝 (2)
      • 코딩 테스트 (2)
      • 기타 (2)

Tag

top150, Coding Test, Backtracking, 티스토리챌린지, array / string, 슬라이딩윈도우, dp, heap, neetcode150, tree, LeetCode, 오블완, leetcode75, dfs, BFS, Two pointers, 우선순위큐, BST, neetcode, 누적합,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2026/02   »
일 월 화 수 목 금 토
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

방문자수Total

  • Today :
  • Yesterday :

Copyright © AXZ Corp. All rights reserved.

티스토리툴바