Return the largest number that is adjacent to a zero - MATLAB Cody - MATLAB Central

Problem 16. Return the largest number that is adjacent to a zero

Difficulty:Rate

This example comes from Steve Eddins' blog: Learning Lessons from a One-Liner

Write a function that takes a list or array of numbers as input and return the largest number that is adjacent to a zero.

Example:

 Input  x = [1 5 3 0 2 7 0 8 9 1 0]
 Output y is 8

This problem was originally posed by Greg Wilson of Software Carpentry.

Solution Stats

35.24% Correct | 64.76% Incorrect
Last Solution submitted on Jun 22, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
1
2

Problem Recent Solvers5428

Suggested Problems

More from this Author96

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!