摘要:
There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to... 阅读全文
摘要:
Reverse a singly linked list.解题思路:用Stack实现,JAVA实现如下: public ListNode reverseList(ListNode head) { if(head==null) return null; St... 阅读全文
摘要:
Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences... 阅读全文
摘要:
Description:Count the number of prime numbers less than a non-negative number, n.解题思路:空间换时间,开一个空间为n的数组,因为非素数至少可以分解为一个素数,因此遇到素数的时候,将其有限倍置为非素数,这样动态遍历+构造... 阅读全文
摘要:
Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 -... 阅读全文
摘要:
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文
摘要:
Given a range [m, n] where 0 >>=1; m>>>=1; count++; } return m<<count; } 阅读全文
摘要:
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen... 阅读全文
摘要:
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For exa... 阅读全文
摘要:
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo... 阅读全文