2017年1月22日星期日

Leetcode Bit操作问题


https://lefttree.gitbooks.io/leetcode-categories/content/BitManipulation/index.html


Bit Manipulation

题目列表

XOR

  • Single Number
  • Single Number II
  • Single Number III
  • Missing Number

&

  • Number of 1 Bits
  • Power of Two

Shift

  • Reverse Bits
  • Reverse Integer
  • Divide 2 Integers

Math

  • Repeated DNA Sequence
  • Bitwise AND of Numbers Range (根据例子找规律,找左边common的部分)

    问题描述

这类题目都涉及到bit的基本操作
  • &
  • |
  • ^
  • ~
  • shift >> and <<
math中的mathwithoutOperator也往往是使用bit manipulation:
  • 乘法,除法 - shft
  • 加法,减法 - ^ 得到carry, ^的到sum, carry再shift

    Reference

没有评论:

发表评论