https://leetcode.com/problems/find-indices-with-index-and-value-difference-i/description/
Find Indices With Index and Value Difference I - LeetCode
Can you solve this real interview question? Find Indices With Index and Value Difference I - You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference. Your task is to find two indices i and j,
leetcode.com
1 2 3 4 5 6 7 8 | class Solution: def findIndices(self, nums: List[int], indexDifference: int, valueDifference: int) -> List[int]: for i in range(len(nums)): for j in range(i+indexDifference, len(nums)): if abs(nums[i] - nums[j]) >= valueDifference: return [i, j] return [-1,-1] | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2824. Count Pairs Whose Sum is Less than Target (1) | 2024.01.02 |
---|---|
leetcode 2729. Check if The Number is Fascinating (0) | 2023.12.29 |
leetcode 2923. Find Champion I (0) | 2023.12.28 |
leetcode 2697. Lexicographically Smallest Palindrome (1) | 2023.12.28 |
leetcode 2828. Check if a String Is an Acronym of Words (0) | 2023.12.28 |
댓글