2013年3月29日

A Distance Maximizing Problem

摘要: Given an array A of integers, findthe maximum of j-i subjected to the constraint of A[i] < A[j].发现这三天做的题目都是一个类型的。 就是采用一个header 一个 tail 指针 同时卡 一个array的两个边界 来在O(n) 的时间内 完成 brute force 需要O(n2) 才能完成的任务。这类问题的相似处都是找max, 采用的 也都是 先移动tail, 当不能移动tail时, 移动header 来动态的控制边界。 阅读全文

posted @ 2013-03-29 07:23 Step-BY-Step 阅读(344) 评论(0) 推荐(0) 编辑

导航