# power of two

power-of-two

class Solution {
public:
bool isPowerOfTwo(int n) {
return n>=1 && !(n&(n-1));
}
};

n=10000***000,
<=> n&(n-1)=0

https://leetcode.com/discuss/40202/only-push-others-using-queue-combination-shared-solutions

class MyStack
{
Queue<Integer> queue;

public MyStack()
{
}

// Push element x onto stack.
public void push(int x)
{
for(int i=0;i<queue.size()-1;i++)
{
}
}

// Removes the element on top of the stack.
public void pop()
{
queue.poll();
}

// Get the top element.
public int top()
{
return queue.peek();
}

// Return whether the stack is empty.
public boolean empty()
{
return queue.isEmpty();
}
}

class Stack {
public:
// Push element x onto stack.
void push(int x) {
q.push(x);
int qsize=q.size();
for(int i=0;i<qsize-1;i++){
q.push(q.front());
q.pop();
}
}

// Removes the element on top of the stack.
void pop() {
q.pop();
}

// Get the top element.
int top() {
return q.front();
}

// Return whether the stack is empty.
bool empty() {
return q.empty();
}
private:
queue<int> q;
};

T(n)=T(n/2)+O(1) 二分 logn

T(n)=2T(n/2)+O(n) 快排，归并 nlogn

T(n)=2T(n/2)+O(1) n 分治等于没治

#### 231. Power of Two [easy] (Python)

2016-05-05 14:47:26

#### 随机的力量(1) - The power of random two choices

2015-11-01 00:43:52

#### leetcode 231: Power of Two

2015-07-07 05:01:24

#### LeetCode 231: Power of Two

2015-07-06 18:34:20

#### leetcode 231. Power of Two 判断是否为2的幂 Java

2016-04-23 16:38:25

#### [LeetCode] Power of Three | Power of Two

2016-01-28 21:39:28

#### Round Up To Power Of Two

2015-08-30 21:33:43

#### Java容器与Hash算法的研究

2016-04-29 11:29:23

#### Non Power of Two Textures

2012-11-08 20:17:58

#### Power Analysis

2014-03-05 16:36:43