Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Doug's Difference Doug was doing his math homework with two of his friends, at one point they all got bored but Doug had an

 

 

image

image

Doug's Difference Doug was doing his math homework with two of his friends, at one point they all got bored but Doug had an idea to pass the time in an interesting way he decided to play a game of difference such that - Given a sequence of integers a, a triplet (a[i],a[i],a[k]) is beautiful if: 1.i EPAM Coding Question No. 1 of 1|| 20 Marks int: the number of beautiful triplets 1.1 CO Coding Question No. 1 of 1 || 20 Marks Sample Output 3 arr[] size n-7, d-3 arr- [1, 2, 4, 5, 7, 8, 10] 7-4-4-1-3-d 10-7-7-4-3-d 8-5-5-2=3=d Sample Input https://mymapit.in/#/test/247358848?testPackid=undefined Explanation. There are many possible triplets (arr[i],arr[j],arr[k]), but our only beautiful triplets are (1,4,7) , (4,7,10) and (2,5,8) by value, not index. Please see the equations below: 73 EPAM 124578 10 Sample Input 10 3 16 7 7 8 10 12 13 14 19 Sample Output 3 Sample Output 2 " D Caution Please do not move away from the window or refresh, you may be marked as suspicious Next Question JAVA (1.8) 1 import java.io.*; 2 3 4 5 6 7 8 9 10-> 11 12 13. H5Ep12345 16 17 18 19 20 22 Import java.util."; import java.text."; import java.math."; import java.util.regex.*; public class Main ( static void getCount(int[] a, int n, int diff) ( } Ma I write your code here. 00:26 public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output Scanner sc new Scanner(System.in); int n sc.nextInt(); int diff sc.nextInt(); int a[]- new int[n]; for(int 1-8;i

Step by Step Solution

3.43 Rating (162 Votes )

There are 3 Steps involved in it

Step: 1

Screen ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Programming questions