摘要: Given an array of numbersnums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements t... 阅读全文
posted @ 2015-10-25 08:34 fenshen371 阅读(180) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you thought about this?Here are som... 阅读全文
posted @ 2015-10-25 07:05 fenshen371 阅读(89) 评论(0) 推荐(0) 编辑
摘要: Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".思路:学习这种代码的简洁写法。 1 class Solution { 2 public: 3 ... 阅读全文
posted @ 2015-10-25 06:50 fenshen371 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of a ... 阅读全文
posted @ 2015-10-25 05:47 fenshen371 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Given apatternand a stringstr, find ifstrfollows the same pattern.Herefollowmeans a full match, such that there is a bijection between a letter inpatt... 阅读全文
posted @ 2015-10-25 05:39 fenshen371 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ... 阅读全文
posted @ 2015-10-25 02:07 fenshen371 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 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?思路:将链表前半部分反转,对比就行了。 1 class Solution... 阅读全文
posted @ 2015-10-25 01:10 fenshen371 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers and an integerk, find out whether there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the differe... 阅读全文
posted @ 2015-10-24 13:48 fenshen371 阅读(88) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Note:Do not modify the linked list.Follow up:Can you sol... 阅读全文
posted @ 2015-10-24 12:44 fenshen371 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:维护两个指针,一快一慢,判断两个指针能否相遇。 1 class Solutio... 阅读全文
posted @ 2015-10-24 11:27 fenshen371 阅读(114) 评论(0) 推荐(0) 编辑