摘要: 题目描述: Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: 解题思路: 开个26个数的数组,然后 阅读全文
posted @ 2016-08-24 00:42 scottwang 阅读(797) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Shuffle a set of numbers without duplicates. Example: 解题思路: 每次往后读取数组的时候,当读到第i个的时候以1/i的概率随机替换1~i中的任何一个数,这样保证最后每个数字出现在每个位置上的概率都是相等的。 证明: 设x元素在第m次的 阅读全文
posted @ 2016-08-24 00:01 scottwang 阅读(2638) 评论(1) 推荐(0) 编辑