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

Codechef Max minus Min problem solution

YASH PAL, 31 July 202427 January 2026

In this Codechef Max minus Min problem solution Chef is given 33 integers A, B,A,B, and CC such that A lt B lt CA<B<C. Chef needs to find the value of max(A, B, C) – min(A, B, C)max(A,B,C)−min(A,B,C).

Here max(A, B, C)max(A,B,C) denotes the maximum value among A, B, CA,B,C while min(A, B, C)min(A,B,C) denotes the minimum value among A, B, CA,B,C.

Codechef Max minus Min problem solution

Codechef Max minus Min problem solution in Python.

# cook your dish here
t=int(input())
while t :
    lst=list(map(int,input().split()))
    print(max(lst)-min(lst))
    t=t-1

Max minus Min problem solution in Java programming.

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int T=sc.nextInt();
		for (int Z=1;Z<=T;Z++){
		    int A=sc.nextInt();
		    int B=sc.nextInt();
		    int C=sc.nextInt();
		    int array[]=new int[3];
		    array[0]=A;
		    array[1]=B;
		    array[2]=C;
		    for (int i=0;i<array.length;i++){
		        for(int j=i+1;j<array.length;j++){
		            if(array[i]>array[j]){
		                int temp=array[i];
		                array[i]=array[j];
		                array[j]=temp;
		            }
		        }
		    }
		  System.out.println(array[array.length-1]-array[0]);
		}
	}
}

Problem solution in C++ programming.

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	for(int i=0;i<t;i++)
	{
	    int x,y,z;
	    cin>>x>>y>>z;
	    int min;
	    int max;
	    if(x>y && x>z)
	    {
	        max=x;
	    }
	    else if(y>x && y>z)
	    {
	        max=y;
	    }
	    else
	    {
	        max=z;
	    }
	    if(x<y && x<z)
	    {
	        min=x;
	    }
	    else if(y<x && y<z)
	    {
	        min=y;
	    }
	    else
	    {
	        min=z;
	    }
	    cout<<max-min<<endl;
	}
	return 0;
}

Problem solution in C programming.

#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int x,y,z;
	    scanf("%d %d %d",&x,&y,&z);
	    printf("%dn",z-x);
	}
	return 0;
}
Codechef Solutions coding problems solutions

Post navigation

Previous post
Next post

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