Question: Your challenge is to take an array of strings and output the longest string in the array. So for

```
["tiny", "small", "bigger", "biggest"]

```

the output would be `biggest`.

If two elements of the array have the same length, you should choose the one that appears first in the array. That means if the array looks like this:

```
["one", "two", "no"]

```

the output is `one`, but if the array looked like this:

```
["two", "one", "no"]

```

the output is `two`.

---

As this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), the shortest code in bytes wins.

Answer: 
[Racket](https://racket-lang.org/), 160 bytes 110 bytes
=======================================================

[Try it online!](https://tio.run/##K0pMzk4t@f9fOScxL12hCMzj4tJISU3LzEvVyFVI1NTITNOw08hJzUsvyQByDSECthrFJUWZeem6EAmN5MQioKQmmmiuRnIKWBwoA1GBJATTowm0L1dBXUPJPy9VSUEppDwfSLrllxaBqMyyVCWgCriCVMJKsCkoBqr4/x8A "Racket – Try It Online") 
First time contributing, advice appreciated!

```
(define(m a)(if(>(length a)1)(if(>=(string-length(car a))(string-length(m(cdr a))))(car a)(m(cdr a)))(car a)))

```

**Ungolfed**

```
(define (m a)
    (if (> (length a) 1)
        (if (>= (string-length (car a)) (string-length (m (cdr a))))
            (car a)
            (m (cdr a))
        )
        (car a)
    )
)

```

Updated solution based on feedback
C++, 125 bytes
==============

Accepts input as a pair of iterators; returns an iterator to the longest string. The array must not be empty (i.e. the iterators must be different).

```c++
#include<algorithm>
template<class I>I f(I a,I b){return std::max_element(a,b,[](auto&a,auto&b){return a.size()<b.size();});}

```

Demo
====

```c++
#include <string>
#include <iostream>
#include <iterator>
int main()
{
    std::string strings[] = { "Programming", "Puzzles", "and", "Code", "Golf" };

    std::cout << *f(std::begin(strings), std::end(strings)) << std::endl;
}

```

The definition of `std::max_element()` guarantees that

> 
> If several elements in the range are equivalent to the greatest element, returns the iterator to the first such element.
> 
> 
>