- 博客(19)
- 收藏
- 关注
原创 206. Reverse Linked List
#206. Reverse Linked List 把一个链表倒转 var reverseList = function(head) { if(!head){ return head; } let new_head = head; let current = null; while(head.next) { ...
2020-01-24 07:27:04 99
原创 64. Minimum Path Sum
#64. Minimum Path Sum Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move eith...
2020-01-24 07:03:19 78
原创 67. Add Binary
#67. Add Binary Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0. Example 1: Input: a = “11”, b = “1” Output...
2020-01-24 06:10:09 96
原创 328. Odd Even Linked List
#328. Odd Even Linked List Example 1: Input: 1->2->3->4->5->NULL Output: 1->3->5->2->4->NULL Example 2: Input: 2->1->3->5->6->4->7->NULL Output: 2...
2020-01-24 05:46:57 90
原创 11. Container With Most Water
#11. Container With Most Water Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at...
2020-01-24 05:20:52 63
原创 228. Summary Ranges
#228. Summary Ranges Example 1: Input: [0,1,2,4,5,7] Output: [“0->2”,“4->5”,“7”] Explanation: 0,1,2 form a continuous range; 4,5 form a continuous range. Example 2: Input: [0,2,3,4,6,8,9] O...
2020-01-24 02:39:13 85
原创 63. Unique Paths II
#63. Unique Paths II A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is tr...
2020-01-18 05:38:11 90
原创 53. Maximum Subarray
#53. Maximum Subarray Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. 这是一个动态规划的问题。当前状态的最大值是上一个状态和上一个状态+当前值的最大值。...
2020-01-18 04:24:44 112 1
原创 459. Repeated Substring Pattern
#459. Repeated Substring Pattern Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given s...
2020-01-18 03:58:16 96
原创 56. Merge Intervals
#56. Merge Intervals 这道题是一道求并集的题。首先把给的数组数组按照数组子项的第0项大小排序。然后比较相邻的两个数组子项,前一项的第1项和后一项的第0项。 var merge = function(intervals) { if(intervals.length<2) return intervals; intervals.sort((a,b) =>...
2020-01-18 03:42:42 83
原创 20. Valid Parentheses
#20. Valid Parentheses Given a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. An input string is valid if: 1.Open brackets must be close...
2020-01-18 01:35:08 65
原创 205. Isomorphic Strings
#205. 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...
2020-01-18 01:25:00 91
原创 686. Repeated String Match
#686. Repeated String Match Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For example, with A = “ab...
2020-01-18 00:46:24 91
原创 31. Next Permutation
#31. Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as ...
2020-01-17 09:18:51 160
原创 543. Diameter of Binary Tree
#543. Diameter of Binary Tree Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in ...
2020-01-17 08:32:13 91
原创 299. Bulls and Cows
#299. Bulls and Cows 这道题是给了两个数字字符串,让你分别找到对应位置数字相同的,和数字相同却不在对应位置的数字的数量。 首先遍历secret,对应位置相同的很好找。然后把位置不对应的放在map里,然后再遍历一遍。 var getHint = function(secret, guess) { let countA = 0; let countB = 0; ...
2020-01-17 08:07:16 213
原创 226. Invert Binary Tree
#226. Invert Binary Tree 这道题是把树的每一个左右子节点交换。 var invertTree = function(root) { if(root !== null) { let temp = root.left; root.left = invertTree(root.right); root.right = in...
2020-01-17 03:43:49 84
原创 1. Two Sum
#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 us...
2020-01-17 03:24:17 84
原创 88. Merge Sorted Array
88. Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively...
2020-01-17 03:15:57 89
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人