2016年3月12日

125. Valid Palindrome

摘要: 1 public class Solution { 2 public boolean isPalindrome(String s) { 3 char[] str = s.toCharArray(); 4 if(str.length == 0) 5 return true; 6 for(int i = 阅读全文

posted @ 2016-03-12 13:07 菜鸟2s 阅读(132) 评论(0) 推荐(0) 编辑

319. Bulb Switcher

摘要: 1.开始采用数组,双重for循环,毫无意外地超时了 class Solution { public: int bulbSwitch(int n) { if(n <= 0) return 0; int *b = new int[n]; for(int i = 0; i < n; ++i) b[i] = 阅读全文

posted @ 2016-03-12 12:32 菜鸟2s 阅读(142) 评论(0) 推荐(0) 编辑

326. Power of Three

摘要: 递归版本: class Solution {public: bool isPowerOfThree(int n) { if(n <= 0) return false; if(n == 1) return true; else if(n%3 == 0) isPowerOfThree(n/3); els 阅读全文

posted @ 2016-03-12 11:28 菜鸟2s 阅读(147) 评论(0) 推荐(0) 编辑

导航