摘要: Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same. If possible, output 阅读全文
posted @ 2018-11-20 16:02 fatttcat 阅读(140) 评论(0) 推荐(0)
摘要: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Example 2: Example 3: 首先用hashmap扫一遍string,统计频率。按频率排序,将ha 阅读全文
posted @ 2018-11-20 13:30 fatttcat 阅读(125) 评论(0) 推荐(0)
摘要: Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runti 阅读全文
posted @ 2018-11-20 13:01 fatttcat 阅读(120) 评论(0) 推荐(0)
摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 阅读全文
posted @ 2018-11-20 12:22 fatttcat 阅读(157) 评论(0) 推荐(0)
摘要: Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. 阅读全文
posted @ 2018-11-20 12:00 fatttcat 阅读(131) 评论(0) 推荐(0)
摘要: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. 阅读全文
posted @ 2018-11-20 03:07 fatttcat 阅读(128) 评论(0) 推荐(0)