# 标签归档：leetcode

## 题目描述：

Implement the following operations of a queue using stacks.

• push(x) -- Push element x to the back of queue.
• pop() -- Removes the element from in front of queue.
• peek() -- Get the front element.
• empty() -- Return whether the queue is ...

## 题目描述：

Given an integer, write a function to determine if it is a power of two.

## Python代码：

``````class Solution:
# @param {integer} n
# @return {boolean ...``````

## 题目描述：

Given a binary search tree, write a function `kthSmallest` to find the kth smallest element in it.

Note:

You may assume k is always valid, 1 ≤ k ≤ BST's total elements.

What if the BST ...

## 题目描述：

Given an integer array of size n, find all elements that appear more than` ⌊ n/3 ⌋ `times. The algorithm should run in linear time and in O(1) space.

Hint:

How many majority elements could it possibly ...

## 题目描述：

Given a linked list, determine if it has a cycle in it.

Can you solve it without using extra space?

## 解题思路：

fast指针每次向前运动两个节点，slow指针每次向前运动一个节点

## Python代码（快慢指针）：

``# Definition for singly-linked list ...``