摘要:
Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. 1 vector > permute(vector &num) { 2 vector > result; 3 if (num.size() == 0) return result; 4 5 std::sort(num.begi... 阅读全文
摘要:
题目:Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime... 阅读全文
摘要:
There are three types of depth-first traversal: pre-order,in-order, and post-order.For a binary tree, they are defined as operations recursively at ea... 阅读全文