Ping World

Map the world!

Designed Linked List

"Algorithms"

Description Design your implementation of the linked list. You can choose to use the singly linked list or the doubly linked list. A node in a singly linked list should have two attributes: val and...

3Sum

"Algorithms"

Description Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution se...

Container With Most Water

"Algorithms"

Description 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 (i, ai) and (i,...

Shortest Unsorted Continuous Subarray

"Algorithms"

Description Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too. Yo...

LeetCode: Find All Numbers Disappeared in an Array

"Algorithms"

Description Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in th...

LeetCode: Move Zeros

"Algorithms"

Description Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. Example: 1 2 Input: [0,1,0,3,12] Output: [1,3,12,...

LeetCode: Majority Element

"Algorithms"

Description Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majori...

LeetCode: Pascal's Triangle

"Algorithms"

Description Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle. In Pascal’s triangle, each number is the sum of the two numbers directly above it. 1 2 3 4 5 6...

Notebook: use database index properly

""

This is a notebook including what I have learned and summarized from the website: use-the-index-luke, all figures are from here as well. Chapter 1. Anatomy of an Index Leaf nodes Index entr...

LeetCode: Search Insert Position

"Algorithms"

Description Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates ...