
JavaScript on Leetcode
文章平均质量分 58
linc101
这个作者很懒,什么都没留下…
展开
-
Isomorphic Strings
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-06-22 21:05:01 · 284 阅读 · 0 评论 -
Count Primes
Description:Count the number of prime numbers less than a non-negative number, n.有三点优化偶数排除掉只除已经判别出来的素数只除小于目标数平方根的数此题决计还有很多优化空间。(待续)/** * @param {number} n * @return {number原创 2015-06-22 22:37:41 · 698 阅读 · 0 评论 -
Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999./** * @param {string} s * @return {number} */var romanToInt = function(s) {原创 2015-06-22 20:11:51 · 258 阅读 · 0 评论 -
[leetcode][javascript]Remove Linked List Elements
Remove Linked List Elements两个版本,一个原始版(196ms),一个略微优化过的版本(176ms)感觉leetcode对js的支持还是有些问题,两版本提交的结果还是有些差异的。/** * Definition for singly-linked list. * function ListNode(val) { * this原创 2015-06-23 20:33:56 · 598 阅读 · 0 评论 -
[leetcode][javascript]Happy Number
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-06-23 22:08:40 · 606 阅读 · 0 评论 -
[leetcode][javascript]Number of 1 Bits
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 00000000原创 2015-06-24 14:01:12 · 312 阅读 · 0 评论 -
[leetcode][javascript]Reverse Bits
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 001110010原创 2015-06-24 21:15:37 · 981 阅读 · 0 评论 -
[leetcode][javascript]Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before c原创 2015-06-24 22:22:45 · 568 阅读 · 0 评论