摘要:
Problem Description:Design an algorithm to encodea list of stringstoa string. The encoded string is then sent over the network and is decoded back to ... 阅读全文
摘要:
An interesting problem. The code is also short and clear.The basic idea is to use a 2d array dp[i][j] to denote the minimum hp that is required before... 阅读全文
摘要:
Problem Description:Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.Note:Given target... 阅读全文
摘要:
Problem Description:There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a li... 阅读全文
摘要:
This link has two nice solutions, one updating from forth to back (posted by tqlong in the post) and the other updating from back to forth (posted by ... 阅读全文
摘要:
There are three methods to solve this problem: bit manipulation, rearrangement of the array, and math tricks.Bit Manipulation1 class Solution {2 publi... 阅读全文
摘要:
Problem Description:Given a strings, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permut... 阅读全文
摘要:
Problem Description:Given a string, determine if a permutation of the string could form a palindrome.For example,"code"-> False,"aab"-> True,"carerac"... 阅读全文
摘要:
The idea and code is just taken from this link. There is a nice explanation to the code on the answer byBrianLuong1337. 1 class Solution { 2 public: 3... 阅读全文
摘要:
No matter what language you use on the OJ, you may refer to Stefan's post for a solution. The C++ is rewritten below, just really concise.1 class Solu... 阅读全文
摘要:
The idea is very simple: just extract the numbers from each version number and compare the numbers from beginning to the end. However, C++ seems to ha... 阅读全文
摘要:
The basic idea is to store the key-value pair in some container. In the following code, we make three type definitions:1 typedef list LI;2 typedef pai... 阅读全文
摘要:
The idea is similar to Strobogrammatic Number II: generate all those in-range strobogrammatic numbers and count.You may refer to this link for a very ... 阅读全文