摘要: 问题:给定一个有序序列1~n,要你将其完全打乱,要求每个元素在任何一个位置出现的概率均为1/n。 解决方案:依次遍历数组,对第n个元素,以1/n的概率与前n个元素中的某个元素互换位置,最后生成的序列即满足要求,1/n的概率可通过rand() % n实现。见如下程序: void swap(int*... 阅读全文
posted @ 2016-05-08 18:31 Free_Open 阅读(334) 评论(0) 推荐(1) 编辑
摘要: Binary Tree Level Order Traversal II My Submissions QuestionEditorial Solution Total Accepted: 79742 Total Submissions: 234887 Difficulty: ... 阅读全文
posted @ 2016-05-08 18:25 Free_Open 阅读(286) 评论(0) 推荐(0) 编辑
摘要: Binary Tree Level Order Traversal My Submissions QuestionEditorial Solution Total Accepted: 102531 Total Submissions: 312211 Difficulty: Easy Given a 阅读全文
posted @ 2016-05-08 16:16 Free_Open 阅读(218) 评论(0) 推荐(0) 编辑
摘要: Binary Tree Inorder Traversal My Submissions QuestionEditorial Solution Total Accepted: 123484 Total Submissions: 310732 Difficulty: Medium... 阅读全文
posted @ 2016-05-08 12:39 Free_Open 阅读(121) 评论(0) 推荐(0) 编辑