摘要:
题目描述:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 ... 阅读全文
摘要:
题目描述:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the ... 阅读全文
摘要:
题目描述:Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?解题思路:对给定的数... 阅读全文
摘要:
题目描述:Given an integer, write a function to determine if it is a power of two.解题思路:判断方法主要依据2的N次幂的特点:仅有首位为1,其余各位都为0.代码如下:public class Solution { publ... 阅读全文
摘要:
题目描述: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 fr... 阅读全文
摘要:
题目描述: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 fr... 阅读全文
摘要:
题目描述:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive in... 阅读全文
摘要:
题目描述:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For ... 阅读全文
摘要:
题目描述:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3,... 阅读全文
摘要:
题目描述:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you ... 阅读全文