- 博客(28)
- 收藏
- 关注
原创 231. Power of Two
原题链接:https://leetcode.com/problems/power-of-two/ 原题:Given an integer, write a function to determine if it is a power of two. 题意:给你一个整数,要你写一个函数去判断这个数是否是2的n次幂 思路:2的n次幂,它的二进制除了首位是1,其余都是0,所以只要判断它二进制是否符合
2016-10-28 17:58:15 135
原创 13. Roman to Integer
原题链接:https://leetcode.com/problemset/algorithms/ 原题:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.题意:给你一个罗马数字的字符串,要求你翻译成整数。 思路: 首先需要知道罗马
2016-10-21 14:45:26 176
原创 206. Reverse Linked List
原题链接:https://leetcode.com/problems/reverse-linked-list/ 原题:Reverse a singly linked list. 题意:要求你反转一个链表 思路:就是反转一个单向链表,三个指针解决,没啥好说的。 AC代码:/** * Definition for singly-linked list. * struct ListNode {
2016-10-21 14:22:45 152
原创 350. Intersection of Two Arrays II
原题链接:https://leetcode.com/problems/intersection-of-two-arrays-ii/ 原题: Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2,
2016-10-21 10:16:34 154
原创 412. Fizz Buzz
原题链接:https://leetcode.com/problems/fizz-buzz/ 原题: Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the numbe
2016-10-15 11:38:50 234
原创 169. Majority Element
原题链接:https://leetcode.com/problems/majority-element/原题: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume tha
2016-10-13 17:28:00 140
原创 415. Add Strings
原题链接:https://leetcode.com/problems/add-strings/原题: Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is < 5100.
2016-10-13 17:04:24 131
原创 1. Two Sum
原题链接:https://leetcode.com/problems/two-sum/原题: Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactl
2016-10-13 00:16:08 133
原创 171. Excel Sheet Column Numb
原题链接:https://leetcode.com/problems/excel-sheet-column-number/原题: Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.Fo
2016-10-12 22:56:55 248
原创 387. First Unique Character in a String
原题链接:https://leetcode.com/problems/first-unique-character-in-a-string/原题: Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1. Example:s
2016-10-12 22:38:06 138
原创 349. Intersection of Two Arrays
原题链接:https://leetcode.com/problems/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
2016-10-12 22:01:11 141
原创 242. Valid Anagram QuestionEditorial Solution
原题链接:https://leetcode.com/problems/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
2016-10-12 16:34:43 141
原创 237. Delete Node in a Linked List
原题链接:https://leetcode.com/problems/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 li
2016-10-09 01:04:31 127
原创 383. Ransom Note
原题链接:https://leetcode.com/problems/ransom-note/原题: Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will re
2016-10-08 21:21:08 194
原创 409. Longest Palindrome
原题链接:https://leetcode.com/problems/longest-palindrome/ 原题: Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those let
2016-10-07 14:36:55 157
原创 404. Sum of Left Leaves
原题链接:https://leetcode.com/problems/sum-of-left-leaves/ 原题: Find the sum of all left leaves in a given binary tree. 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree,
2016-10-07 11:11:33 121
原创 283. Move Zeroes
原题链接: https://leetcode.com/problems/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,
2016-10-07 10:39:23 134
原创 389. Find the Difference
原题链接: https://leetcode.com/problems/find-the-difference/ 题目: Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one mor
2016-10-07 09:49:49 242
原创 226. Invert Binary Tree
原题链接:https://leetcode.com/problems/invert-binary-tree/ 原题: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1题意:就是反转一棵二叉树 思路:还
2016-09-04 19:22:19 140
原创 104. Maximum Depth of Binary Tree
原题链接:104. Maximum Depth of Binary Tree 原题:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
2016-09-04 18:07:09 170
原创 258. Add Digits
原题链接:https://leetcode.com/problemset/algorithms/ 题目: 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 lik
2016-09-04 16:05:15 173
原创 136. Single Number
原题链接:https://leetcode.com/problems/single-number/ 题目: Given an array of integers, every element appears twice except for one. Find that single one. 题意:就是给定了一个数组,里面除了一个数,其他的数字都有重复的两个存在,要你找出这个数字。解题思路:
2016-09-04 00:51:15 147
原创 292. Nim Game
原题链接:https://leetcode.com/problems/nim-game/ 原题: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 ston
2016-09-03 12:05:44 240
原创 344. Reverse String
原题链接:https://leetcode.com/problems/reverse-string/ 题意:要求把字符串反转,直接反转就好了。。。 ac 代码:class Solution {public: string reverseString(string s) { int length=s.length(); if(length==0) retu
2016-07-26 18:44:15 139
原创 100. Same Tree
原题链接:https://leetcode.com/problems/same-tree/ 题意是:给出两个二叉树,判断是否完全相同 解法:题目给出了两棵树的结构体,遍历两棵树每个节点进行比较即可 ac代码/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode
2016-07-26 18:33:22 156
原创 217. Contains Duplicate
原题链接:https://leetcode.com/problems/contains-duplicate/submissions/ 题意就是 如果数组里面有一个数字出现两次以上就return true;无力解释~~~、ac代码class Solution {public: bool containsDuplicate(vector<int>& nums) { if(
2016-07-13 20:31:22 155
原创 8. String to Integer (atoi)
(欢迎大家向我提问交流!!!)原题链接:https://leetcode.com/problems/string-to-integer-atoi/ 原题要求: Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a chall
2016-07-13 13:27:12 245
原创 371. Sum of Two Integers
(有什么问题欢迎和博主讨论!!!)原题链接:https://leetcode.com/problems/sum-of-two-integers/ 这是一道简单的考查位运算的题目(还是能考一下程序员对位运算的了解的)原题要求 Calculate the sum of two integers a and b, but you are not allowed to use the operator
2016-07-13 10:06:22 226
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人