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

分析:
题意是给定一个整数,判断它是不是2的幂。

代码实现:

public class Solution {public boolean isPowerOfTwo(int n) {if(n<1){return false;}if(n==1){return true;}if((n&1)==0) {return isPowerOfTwo(n/2);} else{return false;}}
}

Leet Code OJ 231. Power of Two [Difficulty: Easy]相关推荐

  1. Leet Code OJ 326. Power of Three [Difficulty: Easy]

    题目: Given an integer, write a function to determine if it is a power of three. Follow up: Could you ...

  2. Leet Code OJ 14. Longest Common Prefix [Difficulty: Easy]

    题目: Write a function to find the longest common prefix string amongst an array of strings. 翻译: 写一个函数 ...

  3. Leet Code OJ 118. Pascal's Triangle [Difficulty: Easy]

    题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, ...

  4. Leet Code OJ 88. Merge Sorted Array [Difficulty: Easy]

    题目: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Not ...

  5. Leet Code OJ 110. Balanced Binary Tree [Difficulty: Easy]

    题目: Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced bin ...

  6. Leet Code OJ 219. Contains Duplicate II [Difficulty: Easy]

    题目: Given an array of integers and an integer k, find out whether there are two distinct indices i a ...

  7. Leet Code OJ 172. Factorial Trailing Zeroes [Difficulty: Easy]

    题目: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in ...

  8. Leet Code OJ 206. Reverse Linked List [Difficulty: Easy]

    题目: Reverse a singly linked list. Hint: A linked list can be reversed either iteratively or recursiv ...

  9. Leet Code OJ 38. Count and Say [Difficulty: Easy]

    题目: The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 11 ...

最新文章

  1. UVA 10700 Camel trading
  2. Modelsim初级使用教程
  3. React Native 之 网络请求 fetch
  4. 使用ganglia监控hadoop及hbase集群
  5. 通过一个简单的例子学习Angular Injection Token工作原理
  6. Linux 手动安装Ettercap
  7. Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
  8. 职场提醒:面试失败n次以后
  9. 常用技巧 —— 桶排
  10. linux之service命令
  11. loading怎么关闭 vant_Vant Loading 加载
  12. JAVA排序:快速排序算法
  13. 编好的C语言程序怎么放记事本上运行,怎么用记事本运行程序
  14. 华为:一个中国民族企业的“下半场”在哪里?
  15. 【python中级】linux系统获得计算机网卡流量
  16. 一、深度学习和神经网络
  17. 论文笔记《ST-GRAT: A Novel Spatio-temporal Graph Attention Network for Accurately Forecasting》
  18. 区块链重要基础知识8-1——冷存储以及热存储和他们之间相互如何结合
  19. 通过js点击事件处理防止表单重复提交
  20. 网络协议:网络层传输层

热门文章

  1. 每一个正整数可以表示为3个三角形数之和
  2. FFMPEG音视频解码
  3. 关于寻路算法的一些思考(4):A* 算法的变体
  4. live555 源码分析:简介
  5. 单元测试之JUnit 5 参数化测试使用手册
  6. 嗯?那你来说说用 ArrayList 还是 LinkedList
  7. 面向视频原生,火山引擎发布视频云与边缘云软硬一体的新云解决方案
  8. 【免费活动】字节跳动背后的音视频技术揭秘
  9. 让你的手机浏览器来一场AR风暴
  10. ffplay.c学习-6-⾳视频同步基础