摘要: Q:Given an array of positive and negative integers find the first subarray with zero sum?no 0's will be a part of the input array and handle all the edge casesA:1. iterate through the array once, and take the sum from 0 to every other index of the array.2. If any sum is zero, the subarray from 0 阅读全文
posted @ 2012-06-24 19:23 百分百好牛 阅读(566) 评论(0) 推荐(0) 编辑
摘要: 今天看到一段代码,顺时针打印数组。写得太美了,简洁明了,几乎不用任何注释。转过来,原来是java版的,我改成了C++版。 1 void PrintMatrixClockWise() 2 { 3 int m = 5; 4 int n = 4; 5 int val[4][5] = 6 { 7 {1, 2, 3, 4, 5 }, 8 {6, 7, 8, 9, 1 }, 9 {11, 12,... 阅读全文
posted @ 2012-06-24 19:00 百分百好牛 阅读(482) 评论(0) 推荐(0) 编辑