The 1st Week of ARTS:1-Two Sum 有更新！

|     |   0 浏览

Introduction The tag ARTS is a project that launched by @Hao Chen at his WeiChat group which for discussing technologies in his Articles. The meaning of ARTS: A: Algorithm, solve an Algorithm each week at https://leetcode.com. R: Review, review something important or meaningful for you in last week. T: Technique, improve one or two Techniques that discovered in your daily work. S: Share, share something you like or interested or something special for you. Not only technologies but also life....

The 10th Week of ARTS:206-ReverseLinkedList 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Reverse Linked List Description Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL My Solution package com.silence.arts.leetcode.second; /** * <br> * <b>Function：</b><br> * <b>Author：</b>@author Silence<br> * <b>Date：</b....

The 16th Week of ARTS:Sliding Window Maximum_239 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Sliding Window Maximum Description Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window. My Solution package com.silence.arts.leetcode.stack;....

The 15th Week of ARTS:KthLargest Element in a Stream_703 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm KthLargest Element in a Stream Description Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Your KthLargest class will have a constructor which accepts an integer k and an integer array nums, which contains initial elements from the stream. For e....

The 7th Week of ARTS:94-Binary Tree Inorder Traversal 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Binary Tree Inorder Traversal Description Given a binary tree, return the inorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 \ 2 / 3 Output: [1,3,2] 2. My Solution package com.silence.arts.leetcode.second; import java.util.ArrayList; import java.util.List; /** * <br> * <b>Function：</b><br> * <b&g....

The 3rd Week of ARTS:4-Median of Two Sorted Arrays 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Description 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)). Example 1: nums1 = [1, 3] nums2 = [2] The median is 2.0 Example 2: nums1 = [1, 2] nums2 = [3, 4] The median is (2 + 3)/2 = 2.5 Solution package com.silence.....

The 2nd Week Of ARTS:2-AddTwoNumbers 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Description You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Example Input: (2 ->....

The 13th Week of ARTS:Valid Parentheses_20 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Sort List Description 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 type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considered valid. My Solution pa....

The 8th Week of ARTS:144-Binary Tree Preorder Traversal 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Binary Tree Preorder Traversal Description Given a binary tree, return the preorder traversal of its nodes' values. Example: Input: [1,null,2,3] 1 2 / 3 Output: [1,2,3] My Solution package com.silence.arts.leetcode.second; import java.util.ArrayList; import java.util.List; /** * <br> * <b>Function：</b><br> * <b>....

The 11th Week of ARTS:Sort List_148 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Sort List Description Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 Output: -1->0->3->4->5 My Solution package com.silence.arts.leetcode.list; import java.util.ArrayList; import java.util.List; /*....

The 12th Week of ARTS:LinkedListCycle_141 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Sort List Description Given a linked list, determine if it has a cycle in it. My Solution package com.silence.arts.leetcode.list; /** * <br> * <b>Function：</b><br> * <b>Author：</b>@author Silence<br> * <b>Date：</b>2018-10-21 23:50<br> * <b>Desc：</b>无<br> */ public c....

The 4th Week of ARTS:5-Longest Palindromic Substring 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Description 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. Example 2: Input: "cbbd" Output: "bb" Solution Brute Force package com.silence.arts.leetcode.first; /** * <br> * <b>Function：....

The 6th Week of ARTS:7-ReverseInteger And 9-PalindromeNumber 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm ReverseInteger Description 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 My Solution package com.silence.arts.leetcode.first; /** * <br> * <b>Function：</b><br> * <b>Author：</b>@author Silenc....

The 9th Week of ARTS:16-3Sum Closest 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm 3Sum Closest Description Given an array nums of n integers 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 would have exactly one solution. Example: Given array nums = [-1, 2, 1, -4], and target = 1. The sum that is closest to the targ....

The 5th Week of ARTS:8-String to Integer (atoi) 有更新！

|     |   0 浏览

Introduction Algorithm - Learning Algorithm Review - Learning English Tip - Learning Techniques Share - Learning Influence Let's do it!!! Algorithm Description 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 from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a num....