Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth 2 Fast 2 Furious problem solution

YASH PAL, 31 July 202413 February 2026
In this HackerEarth 2, Fast 2 Furious problem solution Dom and Brian were trying to evade the truck drivers of Verone’s gang. They were too fast, too furious for them, and could get away from the truck drivers easily. They decided to race with each other, and divided the city into N checkpoints for the same. Mia was monitoring Dom and Brian throughout the race and she noted down their speeds at every checkpoint.
 
Roman was jobless, as usual, and told Mia that Dom would definitely have the maximum change in speed between any two consecutive checkpoints. Mia disagreed with him and challenged him that Brian would have a maximum change in speed.
 
Help Mia and Roman to find out who has the maximum change in speed between any two consecutive checkpoints – Dom or Brian.
Note: Both negative and positive changes have to be considered. Hence, the absolute value of maximum change in speed is to be considered.
 
 
HackerEarth 2 Fast 2 Furious problem solution

 

 

HackerEarth 2 Fast 2 Furious problem solution.

#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll a[1000007];

int main() {
int n;
cin>>n;
assert(n>=2 && n<=1000000);
for(int i=0;i<n;i++) {
cin>>a[i];
assert(a[i] >= -1000000000 && a[i] <= 1000000000);
}
ll ret1 = -1;
for(int i=0;i<n-1;i++) ret1=max(ret1,abs(a[i]-a[i+1]));
for(int i=0;i<n;i++) {
cin>>a[i];
assert(a[i] >= -1000000000 && a[i] <= 1000000000);
}
ll ret2 = -1;
for(int i=0;i<n-1;i++) ret2=max(ret2,abs(a[i]-a[i+1]));
if(ret1 > ret2) cout << "Domn";
else if(ret1 < ret2) cout << "Briann";
else cout<<"Tien";
cout<<max(ret1,ret2)<<"n";
}
 
 

Second solution

#include <iostream>
#include <cassert>
using namespace std;


int main()
{
int n, D=0, B=0, prev, cur;
cin>>n;
assert(n>=2 && n<=1000000);
cin>>prev;
assert(abs(prev) <= (int)1e9);
for (int i=1; i<n; i++) {
cin>>cur;
assert(abs(cur) <= (int)1e9);
D = max(D, abs(cur-prev));
prev = cur;
}

cin>>prev;
assert(abs(prev) <= (int)1e9);
for (int i=1; i<n; i++) {
cin>>cur;
assert(abs(cur) <= (int)1e9);
B = max(B, abs(cur-prev));
prev = cur;
}

if (D==B){
cout<<"Tie"<<endl<<D;
}
else if (D>B) {
cout<<"Dom"<<endl<<D;
}
else {
cout<<"Brian"<<endl<<B;
}
return 0;
}
 
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes