2018年2月9日

leetcode 383. Ransom Note

摘要: bool canConstruct(string ransomNote, string magazine) { unordered_map m; for (auto i : magazine) m[i]++; for (auto i : ransomNote) { if (m... 阅读全文

posted @ 2018-02-09 18:36 willaty 阅读(70) 评论(0) 推荐(0) 编辑

leetcode 374. Guess Number Higher or Lower

摘要: 二分。 阅读全文

posted @ 2018-02-09 18:25 willaty 阅读(82) 评论(0) 推荐(0) 编辑

leetcode 371. Sum of Two Integers

摘要: 异或其实是无进位加法,与取进位。 阅读全文

posted @ 2018-02-09 18:15 willaty 阅读(78) 评论(0) 推荐(0) 编辑

leetcode 367. Valid Perfect Square

摘要: 二分。 阅读全文

posted @ 2018-02-09 16:26 willaty 阅读(86) 评论(0) 推荐(0) 编辑

leetcode 350. Intersection of Two Arrays II

摘要: 两个哈希。 阅读全文

posted @ 2018-02-09 13:03 willaty 阅读(132) 评论(0) 推荐(0) 编辑

leetcode 349. Intersection of Two Arrays

摘要: 找出两个数组相同的元素。返回相同的元素集合即可。 两个思路: 1. 先将num1转为集合set1(去重),再遍历num2,查找set1中有没有出现。 2. 哈希,用两个unordered_map<int, bool>,再遍历即可。 这里用方法2: 阅读全文

posted @ 2018-02-09 12:14 willaty 阅读(97) 评论(0) 推荐(0) 编辑

导航