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

HackerEarth Micro and Array Update problem solution

YASH PAL, 31 July 202414 February 2026
In this HackerEarth Micro and Array Update problem solution, Micro purchased an array A having N integer values. After playing it for a while, he got bored of it and decided to update the value of its element. In one second he can increase the value of each array element by 1. He wants each array element’s value to become greater than or equal to K. Please help Micro to find out the minimum amount of time it will take, for him to do so.
 
 
HackerEarth Micro and Array Update problem solution

 

 

HackerEarth Micro and Array Update problem solution.

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

int main(){
int t;cin>>t;
while(t--){
int n, k;cin>>n>>k;
int ans = k;
for(int i=1; i<=n; i++){
int temp;cin>>temp;
ans = min(ans, temp);
}
cout<<k-ans<<endl;
}
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 *

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

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