思路分析:任何一个数字异或它自己都等于0,根据这一特性,如果从头到尾依次异或数组中的每一个数字,因为那些出现两次的数字全部在异或中抵消掉了,所以最终的结果刚好是那些只出现一次的数字. 代码如下: #include "stdafx.h" #include <stdio.h> int findNotDouble(int a[], int n) { ]; int i; ; i < n; ++i) result ^= a[i]; return result; } int ma…
Convert Binary Number in a Linked List to Integer这道题在leetcode上面算作是“easy”,然而小生我还是不会做,于是根据大佬的回答来整理一下思路以便日后复习. https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/ 1.原题: Given head which is a reference node to a singly-linked…
Determine whether an integer is a palindrome. Do this without extra space. class Solution: def isPalindrome(self, x): """ :type x: int :rtype: bool """ x =str(x) for i in range(int(len(x)/2)+1): if(x[i]!=x[len(x)-i-1]): retur…