Skip to content
Programmingoneonone
Programmingoneonone
  • Home
  • CS Subjects
    • IoT ? Internet of Things
    • Digital Communication
    • Human Values
  • 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
Programmingoneonone

HackerEarth Micro and Array Update problem solution

YASH PAL, 31 July 2024
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

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes