Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8719537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:49:22+00:00 2026-06-13T06:49:22+00:00

So as I was going through some practice problems from programming contests (ACM ICPC,

  • 0

So as I was going through some practice problems from programming contests (ACM ICPC, etc), people can often times take an O(N^2) Solution, or even worse, and use a Heap (priority_queue in C++) or a deque to reduce complexity. (as some sort of optimization, after noticing “something” in the pattern)

For example in the “sliding window maximum” problem, which is pretty much:

For each window of size K in an array of size N, compute the maximum.

There’s a trivial O(NK) algorithm, a rather easy O(nlogn) solution (even I can see it, using a heap) and a O(N) solution, using a double ended queue.

These principals seem to be on the principal of “throwing” away useless values, or querying a region to find a property (maximum, cumulative sum, min, etc).

For example to convert some O(N^2) algorithms to O(NlogN), sometimes you can use a priority_queue and keep popping out values until you get one within a certain window, instead of looping through all previous N elements to find a maximum.

Anyone have good tips? (Other than doing more problems… I’m trying to do that)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:49:23+00:00Added an answer on June 13, 2026 at 6:49 am

    Basic of DP Algorithm is splitting problem.

    In order to reducing time complexity, let’s split problem in a different way.

    To embodiment DP algorithm, we use many easy sub-algorithms such as sort, tree(even it’s not algorithm), …

    If you want to reducing time complexity, embody this algorithms more fast.

    If you are using sort, use quick sort or heap sort instead of selection/bubble sort.

    If you want to get min/max value, use heap or priority queue.

    If you can’t make more fast recurrence formula, then reduce time using more fast sub-algorithms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going through some practice problems, and I saw this code: #include <stdio.h> #include
I was going through some practice coding problems , and i came across one
I'm fairly new the functional programming, so I'm going through some practice exercises. I
I am learning some good code practice that's why i was going through some
Going through some of my older Delphi projects and upgrading them to D2009, as
Going through some documentation on modifying CGImageRef data, I came across a strange example
While going through some tutorials, I have encountered lines such as this: ((IDisposable)foo).Dispose(); Ignore
I am going through some code and at the beginning of the script we
I was going through some code that I downloaded off the internet ( Got
I was going through some data structures and I noticed this as a time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.