
leetcode
小麦大大
写写代码纪录生活
展开
-
leetcode每日一道(第一道)
1、Two Sum 两数之和案例:Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 27 = 9, return [0, 1]思路:使用一个HashMap,来建立数字和其坐标位置之间的映射,我们都知道HashMap是常数级的查找效率,这样,我们在遍历数组的时候,用target减去遍历到的数字,...原创 2019-04-22 21:54:06 · 144 阅读 · 0 评论 -
[LeetCode] 验证回文数字(第二道)
验证回文数字例子Example 1:Input: 121Output: trueExample 2:Input: -121Output: falseExplanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome....原创 2019-04-23 20:33:50 · 176 阅读 · 0 评论