Company: IBM_11dec
Difficulty: medium
Coding Problem body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; line-height: 1.6; } h1, h2 { border-bottom: 1px solid #eaecef; padding-bottom: 0.3em; } code { background-color: #f6f8fa; padding: 0.2em 0.4em; margin: 0; font-size: 85%; border-radius: 3px; } pre { background-color: #f6f8fa; padding: 16px; overflow: auto; border-radius: 3px; } table { border-collapse: collapse; margin-top: 1em; } th, td { border: 1px solid #dfe2e5; padding: 6px 13px; } th { font-weight: 600; } ul { padding-left: 20px; } Count Triplets with Bounded Difference Problem Description You are given an array of integers arr and a number d . Select a group of three elements where the difference between the largest and smallest values in the group is at most d . Return the total number of such groups, modulo (10 9 + 7). Examples Example 1 Input: arr = [-3, -2, -1, 0], d = 2 Output: 2 Explanation: Al