【leetcode】203. Remove Linked List Elements
问题描述: Remove all elements from a linked list of integers that have value val. Example Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6 Return: 1 --> 2 --> 3 --> 4 -->…
[leetcode]507. Perfect Number
问题描述: We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, write a function that returns true when it is a perfect number and false when it is not. Example: Input: 28 Output:…
[leetcode]112. Path Sum
问题描述: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ \ 7 2 1 return…
【leetcode】606. Construct String from Binary Tree
【题目】 You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way. The null node needs to be represented by empty parenthesis pair "()". And you need to omit all the empty parenthesis pairs that don't affect the one-to-one mapping relationship between…
【leetcode】9. Palindrome Number
问题描述:Determine whether an integer is a palindrome. Do this without extra space. 翻译:判断一个整数是否为回文序列,要求不要使用额外的存储空间。 【c++版】 class Solution { public: bool isPalindrome(int x) { } }; 解题答案,步骤挺清晰的,思路也清晰: class Solution { public: bool isPalindrome(int x) { string tmp; if(!x) return true; else if(x < 0) return false; // x = abs(…