Practice Prime In Diagonal
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
In square nums, consider cells (i,i) and (i,nums.length - 1 - i) on its two main diagonals. Return the largest prime value among them, or 0 if none exists. A prime is greater than 1 and has no positive divisors other than 1 and itself.
Source: Prime In Diagonal on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [[1,2,3],[5,6,7],[9,10,11]]
Output
11
# Example 2
Input
nums = [[1,2,3],[5,17,7],[9,11,10]]
Output
17
Constraints
1 <= nums.length <= 300
nums.length == numsi.length
1 <= nums[i][j] <= 4*10^6
Related LeetCode Problems
Practice more problems similar to Prime In Diagonal.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.