摘要: 思路源于位运算关于异或^的定律:a^b^b = a, a^0 = a; 1 class Solution { 2 public: 3 int singleNumber(vector<int>& nums) { 4 int res=0; 5 for(auto num : nums) 6 res ^= 阅读全文
posted @ 2016-03-05 21:52 co0oder 阅读(102) 评论(0) 推荐(0) 编辑
摘要: [26]位数组,存储对应字母出现的个数,s、t分别得到不同数组,比较两个数组是否相同。 1 class Solution { 2 public: 3 bool isAnagram(string s, string t) { 4 if(s.length() != t.length()) return 阅读全文
posted @ 2016-03-05 21:34 co0oder 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 不符合的情况有三种:1、pattern和str长度不符 2、pattern中不同字母指向str中同一词(a、b->同一词) 3、同一字母指向不同词(a->不同词) 1 class Solution { 2 public: 3 vector<string> split(string str){ 4 v 阅读全文
posted @ 2016-03-05 21:05 co0oder 阅读(320) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) : val(x), 阅读全文
posted @ 2016-03-05 10:38 co0oder 阅读(127) 评论(0) 推荐(0) 编辑