Palindrome Partitioning ii

Description URL: https://oj.leetcode.com/problems/palindrome-partitioning-ii/ Difficulty: 3.0/5.0 Solution , where . Here $ starts from 1 and min_cut[0] = -1. The key is that when we use to update , the must already be computed. The intuitive solution is to first use...

Word Ladder

Description Difficulty: 2.0/5.0 URL: https://oj.leetcode.com/problems/word-ladder/ Solution This problem requires us to find the shortest path to transform from string s1 to s2. The intermediate string must belong to a dictionary. So this problem can be solved by BFS. We have...

LRU Cache

Description Difficulty: 2.5/5.0 URL: https://oj.leetcode.com/problems/lru-cache/ Solution This problem requires us to implement a LRU cache that supports two operations: get(int key) and set(int key, int val). An unodered_map would suffice for random access with keys and a doubly linked list...

Word Search

Description Difficulty: 1.5/5.0 URL: https://oj.leetcode.com/problems/word-search/ Solution This is a simple problem that can be solved by DFS. The time complexity can be exponential, for example search the word aaaaab in the matrix shown in the figure. class Solution { private:...

Quick Sort

Quick Sort This is an easy implementation of quick sort, the worst case time complexity of which can be , when the array is already sorted. An improvement is to select the pivot randomly. However with a pivot positioned at...