FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 2722,3 "name": "prime-in-diagonal",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/prime-in-diagonal/",6 "date": "2023-04-02",7 "task_description": "You are given a 0-indexed two-dimensional integer array `nums`. Return _the largest **prime** number that lies on at least one of the diagonals of _`nums`. In case, no prime is present on any of the diagonals, return_ 0._ Note that: An integer is **prime** if it is greater than `1` and has no positive integer divisors other than `1` and itself. An integer `val` is on one of the **diagonals** of `nums` if there exists an integer `i` for which `nums[i][i] = val` or an `i` for which `nums[i][nums.length - i - 1] = val`. In the above diagram, one diagonal is **[1,5,9]** and another diagonal is** [3,5,7]**. **Example 1:** ``` **Input:** nums = [[1,2,3],[5,6,7],[9,10,11]] **Output:** 11 **Explanation:** The numbers 1, 3, 6, 9, and 11 are the only numbers present on at least one of the diagonals. Since 11 is the largest prime, we return 11. ``` **Example 2:** ``` **Input:** nums = [[1,2,3],[5,17,7],[9,11,10]] **Output:** 17 **Explanation:** The numbers 1, 3, 9, 10, and 17 are all present on at least one of the diagonals. 17 is the largest prime, so we return 17. ``` **Constraints:** `1 <= nums.length <= 300` `nums.length == numsi.length` `1 <= nums[i][j] <= 4*106`",8 "test_case": [9 {10 "label": "Example 1",11 "input": "nums = [[1,2,3],[5,6,7],[9,10,11]]",12 "output": "11 "13 },14 {15 "label": "Example 2",16 "input": "nums = [[1,2,3],[5,17,7],[9,11,10]]",17 "output": "17 "18 }19 ],20 "constraints": [21 "An integer is prime if it is greater than 1 and has no positive integer divisors other than 1 and itself.",22 "An integer val is on one of the diagonals of nums if there exists an integer i for which nums[i][i] = val or an i for which nums[i][nums.length - i - 1] = val.",23 "1 <= nums.length <= 300",24 "nums.length == numsi.length",25 "1 <= nums[i][j] <= 4*106"26 ],27 "python_template": "class Solution(object):\n def diagonalPrime(self, nums):\n \"\"\"\n :type nums: List[List[int]]\n :rtype: int\n \"\"\"\n ",28 "java_template": "class Solution {\n public int diagonalPrime(int[][] nums) {\n \n }\n}",29 "metadata": {30 "func_name": "diagonalPrime"31 }32}