Suzy Zhang

Home Archives About
2019-04-09
Algorithm

LeetCode/Minimum Cost to Merge Stones

Problem Summary

There are N piles of stones in a row. The i-th pile has Xi stones.

A move consists of merging exactly K consecutive piles into one pile, and the cost of this move is equal to the total number of stones in these K piles.

Find the minimum cost to merge all piles of stones into one pile. If impossible, return -1.

Read More

Share Comments
  • DP
  • LeetCode
2019-04-02
Algorithm

LeetCode/Lexicographical Numbers

Problem Summary

Given an integer n, return all numbers in [1,n] in lexicographical order.

n ≤ 5,000,000.

Read More

Share Comments
  • LeetCode
2019-03-29
Algorithm

LeetCode/Knight Dialer

Problem Summary

Place a knight on a phone pad, and let it hop N-1 times between the numbered keys, generating a N-digit number. Find how many distinct numbers we can dial in this manner.

Read More

Share Comments
  • DFS
  • DP
  • Fast power
  • LeetCode
  • Math
2019-03-29
Algorithm

LeetCode/Regions Cut by Slashes

Problem Summary

Given a N × N grid of 1 × 1 squares, each square consists of a ‘/‘, ‘\’, or blank space. Find the number of regions.

Read More

Share Comments
  • LeetCode
  • Union-find
2017-11-29
Algorithm

LeetCode/Edit Distance

Problem Summary

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)

Read More

Share Comments
  • DP
  • LeetCode
  • String
2017-11-19
Algorithm

LeetCode/Validate Binary Search Tree

Problem Summary

Given a binary tree, determine if it is a binary search tree.

Read More

Share Comments
  • Binary Search Tree
  • LeetCode
2017-11-13
Algorithm

LeetCode/Happy Number

Problem Summary

Write an algorithm to determine if a number is “happy”.

Read More

Share Comments
  • Cycle Detection
  • Graph Theory
  • LeetCode
2017-11-12
Algorithm

LeetCode/Minimum Height Tree

Problem Summary

For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called minimum height trees (MHTs). Given such a graph, find all roots of the MHTs.

Read More

Share Comments
  • LeetCode
  • Topological Sorting
  • Tree
2017-11-11
Algorithm

LeetCode/Recover Binary Search Tree

Problem Summary

Two elements of a binary search tree are swapped. Recover the tree by swapping them again.

Read More

Share Comments
  • Binary Search Tree
  • DFS
  • LeetCode
2017-11-11
Algorithm

LintCode/Wiggle Sort

Problem Summary

Given an unsorted array A, reorder it in-place such that A[0] <= A[1] >= A[2] <= A[3]…

Read More

Share Comments
  • Array
  • LintCode
123…9Next»

Categories

  • Algorithm85
  • Data Structure1

Tags

  • Array5
  • BFS3
  • Big Number1
  • Binary Search7
  • Binary Search Tree5
  • Binary tree1
  • Bit Manipulation3
  • Bucket Sort1
  • Codeforces1
  • Convex Hull1
  • Cycle Detection1
  • DFS4
  • DP23
  • DP on Trees1
  • Dijkstra1
  • Dinic1
  • Fast power1
  • Game Theory1
  • Geometry1
  • Graph Theory16
  • Greedy6
  • HackerRank18
  • Hash2
  • Heap1
  • Hungarian Alogrithm1
  • IDDFS2
  • Implementation2
  • LCA1
  • LeetCode12
  • Linked List3
  • LintCode31
  • MST1
  • Map Reduce1
  • Math1
  • Matrix1
  • Maximum Flow2
  • Merge Sort1
  • Minimum Cut2
  • Minimum length cycle1
  • Number Theory3
  • Partial order1
  • Prim1
  • Pruning2
  • SPFA1
  • Sort3
  • Stack1
  • String3
  • Strongly connected components1
  • Tarjan's algorithm1
  • Topological Sorting2
  • Tree2
  • Trie3
  • Two Pointers1
  • USACO25
  • Union-find1

Archives

  • April 20192
  • March 20192
  • November 201711
  • October 201724
  • September 201718
  • August 201719
  • July 201710

Recent Posts

  • LeetCode/Minimum Cost to Merge Stones
  • LeetCode/Lexicographical Numbers
  • LeetCode/Knight Dialer
  • LeetCode/Regions Cut by Slashes
  • LeetCode/Edit Distance
© 2020 Suzy Zhang
Powered by Hexo
Home Archives About