Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
longest-nice-subarray.json29 linesDownload Raw Back to root
1{2  "id": 2478,3  "name": "longest-nice-subarray",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/longest-nice-subarray/",6  "date": "2022-08-28",7  "task_description": "You are given an array `nums` consisting of **positive** integers. We call a subarray of `nums` **nice** if the bitwise **AND** of every pair of elements that are in **different** positions in the subarray is equal to `0`. Return _the length of the **longest** nice subarray_. A **subarray** is a **contiguous** part of an array. **Note** that subarrays of length `1` are always considered nice. **Example 1:** ``` **Input:** nums = [1,3,8,48,10] **Output:** 3 **Explanation:** The longest nice subarray is [3,8,48]. This subarray satisfies the conditions: - 3 AND 8 = 0. - 3 AND 48 = 0. - 8 AND 48 = 0. It can be proven that no longer nice subarray can be obtained, so we return 3. ``` **Example 2:** ``` **Input:** nums = [3,1,5,11,13] **Output:** 1 **Explanation:** The length of the longest nice subarray is 1. Any subarray of length 1 can be chosen. ``` **Constraints:** `1 <= nums.length <= 105` `1 <= nums[i] <= 109`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "nums = [1,3,8,48,10]",12      "output": "3 "13    },14    {15      "label": "Example 2",16      "input": "nums = [3,1,5,11,13]",17      "output": "1 "18    }19  ],20  "constraints": [21    "1 <= nums.length <= 105",22    "1 <= nums[i] <= 109"23  ],24  "python_template": "class Solution(object):\n    def longestNiceSubarray(self, nums):\n        \"\"\"\n        :type nums: List[int]\n        :rtype: int\n        \"\"\"\n        ",25  "java_template": "class Solution {\n    public int longestNiceSubarray(int[] nums) {\n        \n    }\n}",26  "metadata": {27    "func_name": "longestNiceSubarray"28  }29}