Fork me on GitHub
摘要: 题目: 给定一个包含1-n的数列,我们通过交换任意两个元素给数列重新排序。 求最少需要多少次交换,能把数组排成按1-n递增的顺序,(数组中的元素互不重复)。 比如 初始状态 5 4 3 2 1 。交换5和1的位置 得到 1 4 3 2 5,再交换4 2的位置得到 1 2 3 4 5.只需要两次即可。 阅读全文
posted @ 2017-08-20 22:06 hellowOOOrld 阅读(17743) 评论(7) 推荐(2)
摘要: Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the ave 阅读全文
posted @ 2017-08-20 11:29 hellowOOOrld 阅读(373) 评论(0) 推荐(0)
摘要: Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binar 阅读全文
posted @ 2017-08-20 11:23 hellowOOOrld 阅读(244) 评论(0) 推荐(0)
摘要: Given a binary tree with n nodes, your task is to check if it's possible to partition the tree to two trees which have the equal sum of values after r 阅读全文
posted @ 2017-08-20 11:12 hellowOOOrld 阅读(616) 评论(0) 推荐(0)