摘要: Given a list of non-overlapping axis-aligned rectangles rects, write a function pick which randomly and uniformily picks an integer point in the space 阅读全文
posted @ 2018-10-04 11:19 jasminemzy 阅读(560) 评论(0) 推荐(0) 编辑
摘要: Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proport 阅读全文
posted @ 2018-10-04 11:18 jasminemzy 阅读(521) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 分治法 1.解决自己小三角,交换左右直接孩子。 2.递归,让自己的左右孩子也去做这件事情。 实现: /* 阅读全文
posted @ 2018-10-04 03:15 jasminemzy 阅读(250) 评论(0) 推荐(0) 编辑