leetcode之javascript
文章平均质量分 77
sunmagine
这个作者很懒,什么都没留下…
展开
-
4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and n...原创 2018-09-02 21:04:40 · 91 阅读 · 0 评论 -
15. 3Sum
解法一 /** * @param {number[]} nums * @return {number[][]} */ var threeSum = function(nums) { let number = []; for(let i=0;i<nums.length-2;i++){ for(let j=i+1;j<nums.length-1;j++){ for...原创 2019-01-04 17:36:24 · 72 阅读 · 0 评论 -
13、Roman to Integer
解法一 /** * @param {string} s * @return {number} */ var romanToInt = function(s) { let num=0; for(let i=0;i<s.length;i++){ if(s[i] === 'M' && s[i-1] !== 'C'){ ...原创 2018-12-27 19:41:48 · 78 阅读 · 0 评论 -
12、Integer to Roman
解法一 /** * @param {number} num * @return {string} */ var intToRoman = function(num) { let roman=''; if(Math.floor(num/1000) >=1 ){ // 比1000大 for (let i=0;i<Math.floor(num/1000);i...原创 2018-12-27 17:14:08 · 116 阅读 · 0 评论 -
11、Container With Most Water
解法一 /** * @param {number[]} height * @return {number} */ var maxArea = function(height) { let max=0; for(var i=0;i<height.length;i++){ for(let j=height.length-1;j>0;j--){ ...原创 2018-12-27 14:28:45 · 94 阅读 · 0 评论 -
9. Palindrome Number
题目要求 Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: fals...原创 2018-09-16 18:24:33 · 95 阅读 · 0 评论 -
8. String to Integer (atoi)
题目要求 Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting fr...原创 2018-09-16 17:50:27 · 85 阅读 · 0 评论 -
7. Reverse Integer
问题描述 Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we a...原创 2018-09-16 11:54:55 · 82 阅读 · 0 评论 -
3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", which the length is 3. Example 2: ...原创 2018-09-03 17:35:03 · 87 阅读 · 0 评论 -
5. Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Exa...原创 2018-09-05 20:53:12 · 76 阅读 · 0 评论 -
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same ...原创 2018-09-02 21:11:43 · 106 阅读 · 0 评论 -
14. Longest Common Prefix
解法一 /** * @param {string[]} strs * @return {string} */ var longestCommonPrefix = function(strs) { if (strs === null || strs.length == 0) { return ""; }...原创 2019-01-02 10:55:41 · 85 阅读 · 0 评论