Блог пользователя Tintin

Автор Tintin, 14 лет назад, По-английски

Your text to link here... My dp solution is O(n^2) but here n=50000 and time is 1 sec. Is there any mathematical formula which reduces time within 1 sec. Any hints...Thanks

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
14 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Try this idea: calculate sums in all prefixes (from empty to the whole sequence) and then sum of elements in a some substring is difference of two numbers. Hope this helps. If not, I can give you detailed solution.