[LeetCode] 42. Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1:Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] 2020-01-06 #leetcode #java #javascript #array #two pointer #stack #monotonic stack
[LeetCode] 144. Binary Tree Preorder Traversal Given the root of a binary tree, return the preorder traversal of its nodes’ values. Example 1:Input: root = [1,null,2,3]Output: [1,2,3] Example 2:Input: root = []Output: [] Example 3:Input: 2019-12-16 #leetcode #tree #dfs #java #preorder
[Leetcode] 58. Length of Last Word Given a string s consisting of words and spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-space characters only. Example 1:Input: s = “Hel 2019-12-10 #leetcode #java #javascript #string
[LeetCode] 16. 3Sum Closest Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input 2019-11-13 #leetcode #java #javascript #array #two pointer #two sum
[LeetCode] 143. Reorder List You are given the head of a singly linked-list. The list can be represented as:L0 → L1 → … → Ln - 1 → Ln Reorder the list to be on the following form:L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → …You may not 2019-11-10 #leetcode #java #javascript #two pointer #linked list
[LeetCode] 21. Merge Two Sorted Lists You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the 2019-11-10 #leetcode #java #javascript #sort #linked list #merge sort
[LeetCode] 142. Linked List Cycle II Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null. There is a cycle in a linked list if there is some node in the list that can be reached agai 2019-11-10 #leetcode #java #javascript #two pointer #linked list
[LeetCode] 141. Linked List Cycle Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously fol 2019-11-10 #leetcode #java #javascript #two pointer #linked list
[LeetCode] 19. Remove Nth Node From End of List Given the head of a linked list, remove the nth node from the end of the list and return its head. Example 1:Input: head = [1,2,3,4,5], n = 2Output: [1,2,3,5] Example 2:Input: head = [1 2019-11-08 #leetcode #java #javascript #two pointer #linked list
[LeetCode] 61. Rotate List Given the head of a linked list, rotate the list to the right by k places. Example 1:Input: head = [1,2,3,4,5], k = 2Output: [4,5,1,2,3] Example 2:Input: head = [0,1,2], k = 4Outpu 2019-11-05 #leetcode #java #javascript #two pointer #linked list