摘要: Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Follow up:Wha 阅读全文
posted @ 2018-10-03 09:39 轻风舞动 阅读(525) 评论(0) 推荐(0) 编辑
摘要: Shuffle a set of numbers without duplicates. Example: 给一个没有重复数字的数组,实现重置和洗牌的功能。 解法:遍历数组每个位置,每次都随机生成一个坐标位置,然后交换当前位置和随机位置的数字,这样如果数组有n个数字,那么也随机交换了n组位置,从而达 阅读全文
posted @ 2018-10-03 09:28 轻风舞动 阅读(734) 评论(0) 推荐(0) 编辑
摘要: Given a robot cleaner in a room modeled as a grid. Each cell in the grid can be empty or blocked. The robot cleaner with 4 given APIs can move forward 阅读全文
posted @ 2018-10-03 09:17 轻风舞动 阅读(5010) 评论(0) 推荐(0) 编辑
摘要: A group of friends went on holiday and sometimes lent each other money. For example, Alice paid for Bill's lunch for 10.ThenlaterChrisgaveAlice10.Then 阅读全文
posted @ 2018-10-03 08:41 轻风舞动 阅读(1903) 评论(0) 推荐(0) 编辑
摘要: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For example, 阅读全文
posted @ 2018-10-03 07:05 轻风舞动 阅读(238) 评论(0) 推荐(0) 编辑
摘要: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For example, 阅读全文
posted @ 2018-10-03 02:23 轻风舞动 阅读(340) 评论(0) 推荐(0) 编辑