![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode刷题
凡凡好疲惫
中山大学大四学生
展开
-
leetcode002 Add Two Numbers
题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as原创 2015-09-26 22:26:35 · 373 阅读 · 0 评论 -
leetcode001 Two Sum
一开始想用头部一个指针尾部一个指针的思路来做。后来看了网上的攻略才发现数组是乱序的。网上的思路比较巧妙,用了一个hashmap,其中key值为数组的value,value值为数据的index,查找的复杂度为O(N)代码如下:vector twoSum(vector& nums, int target) { vector ret; map m; for(原创 2015-09-26 22:22:33 · 303 阅读 · 0 评论 -
leetcode009 Palindrome Number
题目:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of conver原创 2015-09-27 23:12:16 · 309 阅读 · 0 评论 -
leetcode007 Reverse Integer
题目要求:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321思路并不难想,这题的难点主要在于溢出的问题,如果溢出需要返回0。因此首先需要得到int类型的最大值和最小值。经过网上查资料,找到两种方法。第一种是用#include头文件,然后使用原创 2015-09-27 14:22:46 · 289 阅读 · 0 评论 -
leet006 ZigZag Conversion
题目要求:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P原创 2015-09-27 13:03:37 · 380 阅读 · 0 评论