摘要: 本试题转自:http://blog.csdn.net/hackbuteer1/article/details/8017703先把题目转过来,之后再给出答案。 阅读全文
posted @ 2013-05-11 21:54 hust_枫 阅读(196) 评论(0) 推荐(1) 编辑
摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are 阅读全文
posted @ 2013-05-11 18:23 hust_枫 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 搜狐笔试题思路: 遍历数组一次,用ret 记录最大的和,sum则将每一个元素加起来;在每一步中若sum < 0,则将sum赋值为0;若sum > 0,则和ret比较,保持ret在每一步中的最大性。最后返回ret即可。code: 1 int find_max_sum(int array[], int n) 2 { 3 //ret 记录maxsum 4 int ret = 0; 5 int sum = 0; 6 7 for (int i = 0; i < n; ++i) 8 { 9 sum += array[i];10 if... 阅读全文
posted @ 2013-05-11 15:02 hust_枫 阅读(147) 评论(0) 推荐(0) 编辑