摘要:
面试题63:股票的最大利润 暴力搜索复杂度O(N^2),换个思路,遍历到某点,只需要记录改点之前最小的点即可,二者之差即为当前最大利润,时间复杂度O(N) 1 int MaxDiff(vector<int> numbers) 2 { 3 int len = numbers.size(); 4 if 阅读全文
摘要:
题目: The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Now your job is to find the to 阅读全文
摘要:
题目: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: Example 1: 阅读全文
摘要:
题目: Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum o 阅读全文