[LC] 2. Add Two Numbers

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 contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Example 1: Input: ...

[LC] 56. Merge Intervals

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. Example 1: Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Input: intervals = [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] ...

[LC] 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] Output: 6 Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. ...

[LC] 200. Number of Islands

Given an m x n 2d grid map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Approach Simple breath first search (BFS). Nothing special. Just keep looking for non visited grid ...

[LC] 146. LRU Cache

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) Initialize the LRU cache with positive size capacity. int get(int key) Return the value of the key if the key exists, otherwise return -1. void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys ...

[LC] 91. Decode Ways

A message containing letters from A-Z can be encoded into numbers using the following mapping: 'A' -> "1" 'B' -> "2" ... 'Z' -> "26" To decode an encoded message, all the digits must be mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "111" can have each of its "1"s be mapped into 'A's to ...

[LC] 1. Two Sum

https://leetcode.com/problems/two-sum/ Question Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Thoughts There is probably a bunch of solution since it is ...

Story of Urhyme project #2

Chapter 2: Urhyme, plan out for life of hundred years. Wireframe, Architecture design and task management By Matthew Chang ([email protected]) When I first started making websites in 1996, rumors started to spread about that I am good at making a homepage, so the teacher asked me to make a website for a class website, then I ...

Story of Urhyme project #1

Date: Oct 25, 2017 Chapter one: The motives for making Urhyme project By Matthew Chang ([email protected]) Finally, I started writing about the Urhyme project. Since 2014, I have spent a lot of time doing a startup building web service called Urhyme. Last week, I deeply thought about the navigation of the Urhyme project. In 2011, ...

Fast development or future-oriented development?

When I think about development, I feel that the most important part is whether I can get the maximum possible operation with minimal resources and prepare for large scale. That’s why I chose the micro service architecture, and if you automatically scale the resources used by the Docker to match the global, you will not worry about ...