![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
文章平均质量分 77
陈小fat
在成为技术大牛的路上。
展开
-
1. Two Sum
#include#includeusing namespace std;class Solution //题目要求提交部分{public:vector twoSum(vector& nums, int target){vector res;for(int i=0; i{for(int j=i+1; j{if(nums[i]+nums[j]原创 2016-06-10 22:56:19 · 50 阅读 · 0 评论 -
Leetcode 9. Palindrome Number
判断回文数,方法有很多。但这里题目要求“Do this without extra space.”也就是说并不建议把整数变为数组再一位一位地判断。所以这里我沿用第七题Discuss版里某位仁兄的做法,先把这个数倒转,再判断它是否跟原来相同。以下是AC的代码:class Solution{ public: bool isPalindrome(int x) { i原创 2016-06-11 18:58:08 · 241 阅读 · 0 评论 -
Leetcode 389. Find the Difference
389. Find the Difference QuestionEditorial Solution My SubmissionsTotal Accepted: 5031Total Submissions: 9334Difficulty: EasyGiven two strings s and t which consist原创 2016-08-29 19:29:32 · 144 阅读 · 0 评论 -
Leetcode 299. Bulls and Cows
299. Bulls and Cows QuestionEditorial Solution My SubmissionsTotal Accepted: 37002Total Submissions: 118547Difficulty: EasyYou are playing the following Bulls and C原创 2016-07-29 10:59:58 · 271 阅读 · 0 评论 -
Leetcode 292. Nim Game
292. Nim Game QuestionEditorial Solution My SubmissionsTotal Accepted: 93357Total Submissions: 172788Difficulty: EasyYou are playing the following Nim Game with原创 2016-08-29 20:32:49 · 136 阅读 · 0 评论 -
Leetcode 344. Reverse String
344. Reverse String QuestionEditorial Solution My SubmissionsTotal Accepted: 77975Total Submissions: 133714Difficulty: EasyWrite a function that takes a string as i原创 2016-08-29 20:49:57 · 111 阅读 · 0 评论 -
Leetcode 136. Single Number
136. Single Number Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could y原创 2016-08-29 23:21:14 · 115 阅读 · 0 评论 -
Leetcode 202. Happy Number
202. Happy NumberWrite an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number原创 2016-08-30 19:15:04 · 136 阅读 · 0 评论 -
Leetcode 258. Add Digits
258. Add Digits Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1原创 2016-08-30 20:06:01 · 141 阅读 · 0 评论 -
Leetcode 283. Move Zeroes
283. Move Zeroes Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0,原创 2016-08-30 23:16:12 · 212 阅读 · 0 评论 -
Leetcode 171. Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 分析:实际上就是求这原创 2016-09-05 18:37:20 · 126 阅读 · 0 评论 -
Leetcode 383. Ransom Note
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constru原创 2016-09-05 20:58:08 · 145 阅读 · 0 评论 -
Leetcode 349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.T原创 2016-09-06 19:47:16 · 104 阅读 · 0 评论 -
Leetcode 242. Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may ass原创 2016-09-07 18:31:58 · 130 阅读 · 0 评论 -
Leetcode 237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value原创 2016-09-07 18:35:42 · 122 阅读 · 0 评论 -
1. Two Sum
class Solution{ public: vector twoSum(vector& nums, int target) { vector res; for(int i=0; i<nums.size()-1; i++) { for(int j=i+1; j<nums.size(); j++) { if(nums[i]+nums[j]==原创 2016-06-11 12:06:20 · 203 阅读 · 0 评论 -
Leetcode 7. Reverse Integer
以下是我AC的代码:class Solution{ public: int reverse(int x) { bool flag=false; if(x<0) { x=-x; flag=true; } vector r; int i=0; while(x>0) { r.push_back(x%10);原创 2016-06-11 13:49:22 · 244 阅读 · 0 评论