leecode第二百三十一题(2的幂)】的更多相关文章

class Solution { public: bool isPowerOfTwo(int n) { bool is_flag=false; ) { ==)//如果为1,看是不是第一个1 { if(is_flag)//如果已经不是第一个1了,直接返回false return false; else is_flag=!is_flag; } n=n>>; } return is_flag; } }; 分析: 还是比较好想出来的.…
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: void deleteNode(ListNode* node) { node->val=node->next->val;//把下个节点复制过来 node->…
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: int k_time; int temp; void kth_min(TreeNode* root) {…
class Solution { public: vector<int> productExceptSelf(vector<int>& nums) { int len=nums.size(); vector<int> res; ,temp=;i<len;i++)//把前面的乘起来,暂存起来 { res.push_back(temp); temp=temp*nums[i]; } ,temp=;i>=;i--)//倒着再乘一遍,刚好错开自己位置的数值 {…
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: void serch_patch(TreeNode* root, TreeNode* node,vecto…
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: TreeNode* lowestCommonAncestor(TreeNode* root, TreeNo…
Bootstrap 介绍 学习要点: 1.Bootstrap 概述 2.Bootstrap 特点 3.Bootstrap 结构 4.创建第一个页面 5.学习的各项准备 本节课我们主要了解一下 Boostrap 历史.特点.用途,以及为什么选择 Boostrap 来开 发我们的 Web 项目. 一.Bootstrap 概述 Bootstrap 是由 Twitter 公司(全球最大的微博)的两名技术工程师研发的一个基于 HTML.CSS.JavaScript 的开源框架.该框架代码简洁.视觉优美,可…
哎,蛋疼的一天,一点破问题搞了一下午,还没搞利索. 他们要组织出去玩,我没有参加啊,随便找了个借口. 博客园的字体怎么变小了呢,看着好难受啊,昨天传照片传的? 睡觉.外边下着雨呢,喜欢下雨的夏天还有下雪的冬天,以及吹着春风的春天和落叶飘零的秋天.…
class Solution { public: bool canWinNim(int n) { )==)//用与的时候,要注意优先级问题 //用n%4==0的时候,其耗时比用&短,但是空间消耗大 return false; else return true; } }; 分析: 经过分析,发现这里面是规律啊,本来还写了个循环,后来觉得不用循环了,直接整吧.…
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* recursive(ListNode* head) { ListNode* pre_node; if(head->next!=NULL) { pre_…