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 8860815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:20:43+00:00 2026-06-14T15:20:43+00:00

I have to solve a problem much like the maximum subarray problem. I have

  • 0

I have to solve a problem much like the maximum subarray problem. I have to find the largest subarray whose average is bigger than k. I thought the following trick. I can transform my array A[] of size n to a B[] where B[i] = A[i] – k. So now the average must be >0. But average greater than zero doesnt simply mean sum greater than zero? So I can directly apply Kadane’s algorithm. Am I right? (always under the constraint that there is 1 positive value)

  • 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-14T15:20:45+00:00Added an answer on June 14, 2026 at 3:20 pm

    no, kadane’s algorithm will still find you the subarray with the biggest sum…i have to solve the same problem. so far i kave find that if we create the array B as you mentioned above and then make the array C which contains the partial sums of the array B,then the maximum interval (i,j) that we are lookink for has the same number for i and j!!! for example:

    array A is: 1 10 -1 -1 4 -1 7 2 8 1 …..and the given k is 5 then
    array B is: -4 5 -6 -6 -1 -6 2 -3 3 -4
    array C is:-4 1 -5 -11 -12 -18 -16 -19 -16 -20
    so the subarray that we are looking for is [7,2,8], has length 3, and has the same first and last element which is -16!!!!

    edit: i forgot to tell that we are searching for a O(n) or an O(n*logn) algorithm…. @lets_solve_it you are right but your algorithm is O(n^2) whitch is way to big for the data we want to handle. i ‘m close to solve it with the function map in c++,whitch is something like a hash table. i thing this is the right diredtion because here the elements of the array C have direct relation with their indexes! Also our professor told us that another possible solution ,is to make again the array C and then take a (special?) pivot to do quicksort….but i don’t totally understand what we expect from quicksort to do.

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

Sidebar

Related Questions

I have been trying to find ways to solve the problem. Firebug said syntax
Please help me solve this problem with capybara I have a button like this
I would like to find an appropriate algorithm to solve this problem: Suppose we
I have been trying to solve this problem for a while, but couldn't with
I have been thinking about a way solve a problem I have and I'm
I have spent some time now to solve a problem for which i have
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
I am trying to solve this problem. I have a series of SELECT statements
I am trying to solve this problem http://www.spoj.pl/problems/PEBBMOV/ . I think I have the
I'm hoping people have some ideas to help solve this problem. I am developing

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.