- 博客(9)
- 收藏
- 关注
原创 Isomorphic Strings -- leetcode
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 of a character must be replaced with anot
2015-07-12 18:01:30 326
原创 Count Primes -- leetcode
Description:Count the number of prime numbers less than a non-negative number, n.基本思路:筛法1, 2 为素数, 筛掉以2为因子的数。 即 2 * 2, 2*3, 2*4,2*52, 寻找到下一个未被筛除的数,如3. 再筛掉以3为因子的数。3, 重复步骤2.时间复杂度为O(n)
2015-07-12 14:53:07 620
原创 Remove Linked List Elements -- leetcode
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 --> 3 --> 4 --> 5/** * Definit
2015-07-12 13:54:16 459
原创 Happy Number -- leetcode
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, replace the number by the sum of the squares
2015-07-11 22:44:38 415
原创 Bitwise AND of Numbers Range -- leetcode
Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4.算法一:使用异或一个范围内所有的数作位与运算,结果是高位相同部分保存不变,低位为0.我们要做的是,如何求出这个分界位置。不需要对范围中每个数,作位与运算,仅需对两个端点作异或运算。异或运算是,
2015-07-11 18:40:59 410
原创 Number of Islands -- leetcode
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 adjacent lands horizontally or vertically. You may assu
2015-07-07 19:27:13 450
原创 Binary Tree Right Side View -- leetcode
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 example:Given the following binary tree, 1
2015-07-07 07:31:28 488
原创 House Robber -- leetcode
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 you from robbing each of them is that adjacent house
2015-07-06 15:24:17 383
原创 Repeated DNA Sequences -- leetcode
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.Wri
2015-07-01 19:33:34 430
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人