Back to questions

Same Stripes ServiceNow Python Interview Question

Same Stripes

ServiceNow Python Interview Question

You are given an matrix. Your task is to determine if the matrix has diagonal stripes where all elements in each diagonal from top-left to bottom-right are of the same stripe—that is, they are identical.

In this context, each diagonal stripe runs from the top-left corner to the bottom-right corner of the matrix. Check if every diagonal stripe consists entirely of the same number.

Return if all diagonal stripes are of the same stripe, otherwise return .

Example #1

Same Stripe DataLemur Example 1

Input: matrix =

Output:

Explanation:
In this grid, the diagonals are:

All elements in each diagonal ar identical. Thus, the answer is .

Example #2

Input: matrix =

Output:

![Same Stripe DataLemur Example 2]

Explanation:
The diagonal does not consist of elements of the same stripe.

Input

Python

Output