You are not logged in. Please login at www.codechef.com to post your questions!

×

BYTES11 - Editorial

Problem Description : Given an array of N integers we have to find the largest subarray with maximal gcd .

Problem Type : Easy / Adhoc type

Short Explanation :

Let the maximal number in the array be " M " .We have to find the largest subarray with all its numbers being M .

Detailed Explanation :

We first have to see what the maximal gcd of the array can be .

It can simply be found by traversing the array and finding the maximal number .To find the largest subarray with maximal gcd we simply have to find the largest subarray with all its numbers being the maximum number of the array . This can be done in O(n) by simply increasing the counter if maximum number found otherwise setting it to zero . In the end the maximum subarray is the answer .

Complexity :O(n)

Solution :https://ideone.com/ZVZsu3

Related Problems :

Practice : https://www.codechef.com/problems/BYTES11

Contest : https://www.codechef.com/BYTE2016/problems/BYTES11

asked 23 Mar '16, 18:00

arpitdec5's gravatar image

4★arpitdec5
61
accept rate: 0%

edited 24 Mar '16, 15:19

admin's gravatar image

0★admin ♦♦
19.7k350498541

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×15,629
×1,167
×934
×20

question asked: 23 Mar '16, 18:00

question was seen: 395 times

last updated: 24 Mar '16, 15:19