LeetCode(9)Palindrome Number】的更多相关文章

题目: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string, note the restriction of using extra space. You could…
题目 Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? 分析 由上一题改动而来,LeetCode 136 Single Nu…
题目 Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 分析 判断一个链表是否为回文. 要求时间复杂度O(n) 空间复杂度O(1) 若是可用辅助空间,则其是一个简单的题目,我们可用利用一个辅助数组存储节点元素val值,然后判断数组是否回文即可. 题目要求O(1)的空间复杂度,不能用辅助空间.我们只能从链表本身下手,…
题目 Write 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 by the sum of the squares of its digits, and repeat the process until…
题目 Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return [ ["aa","b"], ["a","a",&q…
题目 Additive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the sequence must be the sum of the preceding two. Fo…
题目 Validate if a given string is numeric. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true Note: It is intended for the problem statement to be ambiguo…
题目 Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. For example: Given nums = [1, 2, 1, 3, 2, 5], return [3, 5]. Note: The ord…
题目 Given an array containing n distinct numbers taken from 0, 1, 2, -, n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note: Your algorithm should run in linear runtime complexity. Could you implement it…
题目 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 you implement it without using extra memory? 分析 给定一个序列 找出只出现一次的元素,其它元素均出现2次: 要求线性时间,不…