摘要:一、题意 Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operatio
阅读全文
摘要:一、题意 In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path w
阅读全文
摘要:一、题意 There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Th
阅读全文
摘要:转载自:https://www.cnblogs.com/flightless/p/10745318.html class Solution { public: static bool cmp(int a, int b){ return a>b; } int main(vector<int>& vec
阅读全文
摘要:一、题意 Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. After doing
阅读全文
摘要:一、题目 Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder an
阅读全文
摘要:一、题目: A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only
阅读全文
摘要:本文参考博文判断一个数是不是质数(素数),3种方式介绍,原文章解释的已经很详细,本问增加部分博主自己的理解。 一、概念介绍 质数:质数是指在大于1的自然数中,除了1和它本身以外不再有其他因数的自然数。特别的0,1不是质数。 二、方法介绍 1.最直接的方法 bool isPrime(int n){ i
阅读全文