Leetcode
等芦荟开花
这个作者很懒,什么都没留下…
展开
-
Leetcode 345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".class Solution {public: string reverseVowels(string s)原创 2016-05-10 17:14:10 · 243 阅读 · 0 评论 -
Leetcode 9. Palindrome Number
Determine whether an integer is a palindrome.Do this without extra space.回文数:1.负数不是回文数;2.逆序和正序表示的数字相同。solution 1:(with extra space.)class Solution {public: bool isPalindrome(int x) {原创 2016-05-10 17:44:55 · 171 阅读 · 0 评论 -
Leetcode 141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:定义两个指针,一个每次只走一步,另一个每次走两步。如果存在环,两个指针迟早会相遇;如果不存在环,则会相继到达终点++NULL。/** * Def原创 2016-05-24 11:06:41 · 199 阅读 · 0 评论 -
Leetcode 7. Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321class Solution {public: int reverse(int x) { int xx=x; if(x<0)x=-x; long原创 2016-05-11 16:27:44 · 173 阅读 · 0 评论 -
Leetcode 36.Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially fille原创 2016-05-20 17:22:44 · 208 阅读 · 0 评论