LeetCode
梦见阳光。。
喜欢前端的妹纸
展开
-
扁平化数组
/*已知如下数组: var arr = [ [1, 2, 2], [3, 4, 5, 5], [6, 7, 8, 9, [11, 12, [12, 13, [14] ] ] ], 10]; 编写一个程序将数组扁平化去并除其中重复部分数据,最终得到一个升序且不重复的数组 */ function flatArray(arr, re=[]) { for (const item of arr) { ...原创 2019-11-13 08:43:08 · 169 阅读 · 0 评论 -
Get Url Query Params
//查询URL中的参数 function getUrlQueryParams(url) { let args={}; if (!url) { return args; } let qs = url.split('?'); if (qs.length < 2) { return args; } let items = qs[1].split('&...原创 2019-06-14 09:03:23 · 451 阅读 · 0 评论 -
Valid Parentheses
// Given a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. // // An input string is valid if: // // Open brackets must be closed by t...原创 2019-05-27 09:03:15 · 70 阅读 · 0 评论 -
Remove Duplicates From Sorted Array
// Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. // // Do not allocate extra space for another array, you must do this by...原创 2019-05-27 09:00:29 · 67 阅读 · 0 评论 -
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: -...原创 2019-05-17 08:59:01 · 99 阅读 · 0 评论 -
Roma To Integer
// 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: -...原创 2019-05-16 09:01:25 · 120 阅读 · 0 评论 -
Reverse Number
/** * @param {number} x * @return {number} */ var reverse = function(x) { let str = x < 0 ? -x : x; str = str.toString(); str = parseInt(str.split('').reverse().join('')); x = x < 0 ?...原创 2019-05-16 08:59:54 · 296 阅读 · 0 评论 -
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...原创 2019-05-16 08:58:47 · 53 阅读 · 0 评论 -
Longest Common Prefix
// Given a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. // An input string is valid if: // Open brackets must be closed by the same ty...原创 2019-05-21 08:51:09 · 74 阅读 · 0 评论