Refresh to get another 5 random questions

Max of two integers

Max of two integers without using any conditional operators.

Tags: algorithm

Travel Distance

*
One train leaves Los Angeles at 15mph heading for New York. Another train leaves from New York at 20mph heading for Los Angeles on the same track.
If ...


M.A.E.

When M.A.E is preferred over M.S.E.? How to optimize the former, since it's not 2nd derivable?


Passengers on an airplane

An airplane has n seats, and all of them have been sold for a particular flight, with no overbooking. When the last passenger arrives, he finds that his seat is ...


Find the majority element

Given an array of size N, determine if there is a majority element that has appeared more than N/2 times.
Output this element if the answer is Yes.