上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 22 下一页
摘要: Description:Count the number of prime numbers less than a non-negative number,n.思路:一个一个判断,时间复杂度:O(n^2)代码:TLEpublic class Solution { public int coun... 阅读全文
posted @ 2015-07-13 15:38 Maydow 阅读(129) 评论(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-07-13 14:45 Maydow 阅读(144) 评论(0) 推荐(0) 编辑
摘要: Reverse a singly linked list.思路:新建一个ListNode,最后返回这个ListNode.next。中间使用两个临时指针一个指向原来的链表头,一个指向新的链表的next.每次循环都往里面插入新的tempNode.时间复杂度:O(n)代码: public ListN... 阅读全文
posted @ 2015-07-13 13:39 Maydow 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 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-13 09:49 Maydow 阅读(154) 评论(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-07-12 18:53 Maydow 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()... 阅读全文
posted @ 2015-07-12 17:41 Maydow 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1思路:利用temp进行交换,采用递归从顶至下,终止条件本身为空或者是叶子节点。... 阅读全文
posted @ 2015-07-12 16:55 Maydow 阅读(129) 评论(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"].思路:采用双指针 ... 阅读全文
posted @ 2015-07-12 16:31 Maydow 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Given an integer, write a function to determine if it is a power of two.判断一个数是不是2的幂。思路,找出该数中二进制位1的个数时间复杂度:O(n)代码: public boolean isPowerOfTwo(int n... 阅读全文
posted @ 2015-07-12 15:46 Maydow 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front o... 阅读全文
posted @ 2015-07-12 15:31 Maydow 阅读(163) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 22 下一页