导航

2015年7月31日

摘要: Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d... 阅读全文

posted @ 2015-07-31 21:01 骄阳照林 阅读(107) 评论(0) 推荐(0) 编辑

摘要: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr... 阅读全文

posted @ 2015-07-31 20:14 骄阳照林 阅读(96) 评论(0) 推荐(0) 编辑

摘要: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: ... 阅读全文

posted @ 2015-07-31 19:49 骄阳照林 阅读(128) 评论(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-07-31 18:02 骄阳照林 阅读(93) 评论(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-07-31 17:38 骄阳照林 阅读(93) 评论(0) 推荐(0) 编辑

摘要: Given an integer, write a function to determine if it is a power of two.Credits:Special thanks to@jianchao.li.fighterfor adding this problem and creat... 阅读全文

posted @ 2015-07-31 14:57 骄阳照林 阅读(117) 评论(0) 推荐(0) 编辑

摘要: Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"].Credits:S... 阅读全文

posted @ 2015-07-31 14:39 骄阳照林 阅读(128) 评论(0) 推荐(0) 编辑

摘要: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired bythis... 阅读全文

posted @ 2015-07-31 10:49 骄阳照林 阅读(95) 评论(0) 推荐(0) 编辑