上一页 1 ··· 6 7 8 9 10
摘要: Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algorithm should use only constant space. You maynotmodify the values in the list, only nodes itself can be changed.---Solution1: Interat 阅读全文
posted @ 2013-09-02 02:35 LEDYC 阅读(282) 评论(0) 推荐(0)
摘要: Determine whether an integer is a palindrome. Do this without extra space.---public class Solution { public boolean isPalindrome(int x) { if(x = 10){ div *= 10; } while(x > 0){ int l = x / div; int r = x % 10; if(l !... 阅读全文
posted @ 2013-08-30 00:50 LEDYC 阅读(157) 评论(0) 推荐(0)
摘要: Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.Notes:It is intended for this problem to be specified vaguely (ie, no given input specs). You are respo 阅读全文
posted @ 2013-08-30 00:09 LEDYC 阅读(224) 评论(0) 推荐(0)
摘要: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321---public class Solution { public int reverse(int x) { boolean sign = x >=0; if(x 0){ int i = x % 10; rst = rst * 10 + i; x = x / 10; } ... 阅读全文
posted @ 2013-08-30 00:03 LEDYC 阅读(132) 评论(0) 推荐(0)
摘要: You are given two linked lists representing two non-negative numbers.The digits are stored in reverse order and each of their nodes contain a single digit.Add the two numbers and return it as a linked list.Input:(2 -> 4 -> 3) + (5 -> 6 -> 4)Output:7 -> 0 -> 8---Solution1: iterative 阅读全文
posted @ 2013-08-29 12:40 LEDYC 阅读(179) 评论(0) 推荐(0)
摘要: Problem:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the lengt 阅读全文
posted @ 2013-08-29 12:16 LEDYC 阅读(184) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10