×

# CL16BA - Editorial

Author: Subham Das
Tester: Soumik Sarkar
Editorialist: Soumik Sarkar

CAKEWALK

# PREREQUISITES:

Basic knowledge of arrays or lists.

# PROBLEM:

Determine the largest value in an array and compare it to a given value.

# EXPLANATION:

An array of N values is provided along with a value M. The maximum value in the array needs to be determined, let's call it maxval. The simple algorithm given below can be used to obtain maxval.

maxval = 0
for each val in N
if maxval < val
maxval = val

Now we have obtained maxval. The next step we perform is to check whether maxval is less than M. If it is less than M, we output "RESIGN" else we output the value of maxval.

if maxval < M
print "RESIGN"
else
print maxval

Complexity of this approach is $\mathcal{O}(N)$.

# AUTHOR'S AND TESTER'S SOLUTIONS:

Author's solution can be found here.
Tester's solution can be found here.

This question is marked "community wiki".

6★meooow ♦
7.3k720
accept rate: 48%

19.8k350498541

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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,852
×1,688
×862
×18
×1

question asked: 14 Oct '16, 22:48

question was seen: 462 times

last updated: 07 Jun '17, 17:28