Skip to content
Programming101
Programming101

Learn everything about programming

  • 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
Programming101
Programming101

Learn everything about programming

HackerEarth Criminals: Little Deepu and Little Kuldeep problem solution

YASH PAL, 31 July 2024
In this HackerEarth Criminals: Little Deepu and Little Kuldeep problem solution Little Deepu and Little Kuldeep are world renowned criminals. But, they are not bad people at heart. (Oh, they are…) Anyway, their occupation is to smuggle drugs from one place to another. And both of them are partners in this occupation of theirs. But, now Little Deepu is an amateur drug seller, while Little Kuldeep is a professional at that.
So, every drug box Little Deepu packs has a value X, that is to say, if there are 5 packets, every packet has some high quantity of a given number. A packet can fit inside another packet easily, iff Xi < Xj – and one packet can contain only ONE packet inside it.
So, when Little Kuldeep receives all the packets from Deepu, he decides to reduce the number of total packets for easier smuggling; can you help Little Kuldeep extend his business, by letting him know the minimum number of packets required for him to successfully smuggle the drugs?
HackerEarth Criminals: Little Deepu and Little Kuldeep problem solution in java python c++ c and javascript programming with practical program code example and explanation

HackerEarth Criminals: Little Deepu and Little Kuldeep problem solution.

#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(),v.end()

#define read(a) freopen("a.txt","r",stdin)
#define write(b) freopen("b.txt","w",stdout)

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define maxall(v) *max_element(all(v))
#define minall(v) *min_element(all(v))

#define pb push_back
#define mk make_pair

#define REV(x) reverse(x.begin(),x.end())
#define SORT(v) sort(all(v))
#define UN(v) SORT(v), (v).earse(unique(all(v)),v.end())

#define common(a,b) SORT(a), SORT(b), a.erase(set_intersection(all(a),all(b),a.begin()),a.end())
#define uncommon(a,b) SORT(a), SORT(b), a.erase(set_symmetric_difference(all(a),all(b),a.begin()),a.end())

#define FILL(a,d) memset(a,d,sizeof(a))

#define LL long long
#define PI 2*acos(0.0)
#define pi pair<int,int>
#define MAXM 2147483647
#define MAXML 9223372036854775807LL
#define MODM 1000000007

LL gcd(LL a, LL b){if(a==0)return(b);else return(gcd(b%a,a));}
LL fastpow(LL a, LL n, LL temp){if(n==0) return(1);if(n==1)return((a*temp)%MODM); if(n&1)temp=(temp*a)%MODM;return(fastpow((a*a)%MODM,n/2,temp));}

/*Template part gets over, finally. */


int main()
{
int n, finalans, tc;
int a[130000];
scanf("%d",&tc);
while (tc--) {
scanf("%d", &n);

for(int i=1;i<=n;i++) {
scanf("%d", &a[i]);
}

sort(&a[1], &a[n+1]);

finalans=0;
int i, j;
for(i=1;i<=n;i=j) {
for(j=i+1;j<=n && a[i]==a[j];j++);
finalans=finalans<j-i?j-i:finalans;
}
printf("%dn", finalans);
}
return 0;
}

Second solution

#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
int test,N,X;
cin>>test;
while(test--)
{
cin>>N;
int a[N];
for(int i=0;i<N;i++)
cin>>a[i];
sort(a,a+N);
int Start=0,End=1;
bool flag=true;
for(Start=0;Start<N && End<N;Start++)
{
flag=false;
//find first index where value is greater than a[i] and put box in it.
for(;End<N;End++)
{
if(a[End]>a[Start]){
End++;
flag=true;
break;
}
}
}
if(flag )
cout<<End-Start<<endl;
else
cout<<End-Start+1<<endl;
}
return 0;
}
coding problems solutions

Post navigation

Previous post
Next post
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
How to download udemy paid courses for free

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
©2025 Programming101 | WordPress Theme by SuperbThemes