NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Alice and Bob work in a beautiful orchard. There are N apple trees in the orchard. The apple trees are arranged in a row and they are numbered from 1 to N Alice is planning to collect all the apples from K consecutive trees and Bob is planning to collect all the apples from L consecutive trees. They want to choose two disjoint segments (one consisting of K trees for Alice and the other consisting of L trees for Bob) so as not to disturb each other. What is the maximum number of apples that they can collect? Write a function: class Solution f public int solution intu A, int K, int L h that, given an array A consisting of N integers denoting the number of apples on each apple tree in the row and integers K and L denoting respectively, the number of trees that Alice and Bob can choose when collecting, returns the maximum number of apples that can be collected by them, or -1 if there are no such intervals. For example, given A s16, 1, 4, 6, 3. 2,7, 4l K 3, L-2, your function should return 24, because Alice can choose trees 3 to 5 and collect 4 6 3 13 apples, and Bob can choose trees 7 to 8 and collect 7 4 11 apples. Thus they will collect 13 11 324 apples in total, and that is the maximum number that can be achieved. Given A 10,19, 15l, K 2, L 2, your function should return -1.because it Test output not possible for Alice and Bob to choose two disjoint intervals Assume that N is an integer within the range 12.600); K and L are integers within the range (1 N-1; each element of array A is an integer within the range 500 in your solution, focus on correctness. The performance of your solution Custom test cases ov10
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.