为了正确统计满足条件的下标对 (i,j) 且 i < j,我们需要:
可以采用以下方法:
给定一个整数数组 A,长度为 n 。在给定一个整数 K ,定义下标对 (i,j)(满足i<j),如果 A[i]−A[j]≥K,为「K-统治对」。
统计并返回数组中所有「K-统治对」的数量。
Scan the QR code below with WeChat to sign in
First-time scan will create your account automatically
请使用微信扫描下方二维码完成注册