摘要: The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font fo... 阅读全文
posted @ 2015-09-08 12:58 茜茜的技术空间 阅读(316) 评论(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?根据回文串的特点,我们需要比较对应位置的值是否相等,那么我们首先需要找到... 阅读全文
posted @ 2015-09-08 11:28 茜茜的技术空间 阅读(224) 评论(0) 推荐(0) 编辑
摘要: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is1 -> 2 -> 3 -> ... 阅读全文
posted @ 2015-09-08 10:07 茜茜的技术空间 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For examp... 阅读全文
posted @ 2015-09-08 08:53 茜茜的技术空间 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Given an integer, write a function to determine if it is a power of two.Java code:(两种方法,第二种方法很妙,用到了bit wise )第二种方法解题思路:如果一个整数是2的幂,那么它的二进制形式最高位为1,其余各位为... 阅读全文
posted @ 2015-09-08 08:33 茜茜的技术空间 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321Have you thought about this?Here are some good questions to ask... 阅读全文
posted @ 2015-09-08 08:08 茜茜的技术空间 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like:3 + ... 阅读全文
posted @ 2015-09-08 04:08 茜茜的技术空间 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Question:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.简单介绍一下罗马数字,摘自维基百科罗马数字共有7个,即I(1)、V(5... 阅读全文
posted @ 2015-09-08 03:19 茜茜的技术空间 阅读(176) 评论(0) 推荐(0) 编辑