Mitsogo Coding Questions & Solutions 2024 | Mitsogo Coding Questions and Answers | Mitsogo Coding Questions | Mitsogo Round 2 Coding Questions
Mitsogo Coding Questions & Solutions 2024: The Coding Questions and Answers is very important in the IT Sector and Private Job Sector. Now days candidates are mostly interested in the off-Campus drive and private jobs. Eagerly prepare for the Coding Interview, Assessment Test, and attend the many samples online test for Private jobs. Following of the hiring, Mitsogo issued the Off Campus Drive for eligible and capable candidates. The Mitsogo Hiring selection process coding test, technical test etc., The Coding Interview round will be asked many questions through sample of C, C++, Java, Python Programming Languages. Thoroughly prepare for the Mitsogo Coding Interview. Here we uploaded major common Mitsogo Coding Questions and Mitsogo Round 2 Coding Questions and Answers. Applicants must prepare Mitsogo Coding Interview Questions and Answers.
You have spent a time to solve the Mitsogo Coding Questions while using this page. The Very Mitsogo Round 2 Coding Interview questions consist of each programming languages. So, candidates prepare all programming languages on one by one. Variety of the sample Infosys Off campus Coding Interview Questions makes confidence to attend the Mitsogo Off Campus drive. Once you have selected in the Mitsogo coding Interview round, you will be move on further selection process. The coding interview round is main part of the Mitsogo Hiring. Candidates focused to prepare Mitsogo Coding Questions and Mitsogo Coding Interview Questions and Answers.
Mitsogo Coding Questions with Answers
Q) Problem Description :
Stepping Numbers are numbers in which the adjacent digits differ by 1. For example, 123, 545, and 98 are stepping numbers, while 321, 444, and 75 are not. The task is to find all stepping numbers in a given range [n, m].
- For example
- Range: [100, 500]
- Stepping Numbers: 101, 121, 123, 210, 212, 232, 234, 321, 323, 343, 345
- Explanation: The stepping numbers between 100 and 500 are 101, 121, 123, 210, 212, 232, 234, 321, 323, 343, and 345. These numbers have adjacent digits that differ by 1.
Write code to find out all the stepping numbers in the given range.
Input Format: First line contains two numbers N,M
Output Format: Print all the stepping numbers present in the range.
Constraints: 0 <= N < M <= 1,000,000,000
C++ Program
#include<bits/stdc++.h> using namespace std; void displaySteppingNumbers(int n, int m) { queue q; for (int i = 1; i <= 9; i++) { q.push(i); } while (!q.empty()) { int stepNum = q.front(); q.pop(); if (stepNum >= n && stepNum <= m) { cout << stepNum << " "; } if (stepNum == 0 || stepNum > m) { continue; } int lastDigit = stepNum % 10; int stepNumA = stepNum * 10 + (lastDigit - 1); int stepNumB = stepNum * 10 + (lastDigit + 1); if (lastDigit == 0) { q.push(stepNumB); } else if (lastDigit == 9) { q.push(stepNumA); } else { q.push(stepNumA); q.push(stepNumB); } } } int main() { int n, m; cout << "Enter the range [n, m]: "; cin >> n >> m; cout << "Stepping Numbers between " << n << " and " << m << ": "; displaySteppingNumbers(n, m); return 0; } Java Program
import java.util.LinkedList; import java.util.Queue; public class Main { public static void displaySteppingNumbers(int n, int m) { Queue queue = new LinkedList<>(); for (int i = 1; i <= 9; i++) { queue.add(i); } while (!queue.isEmpty()) { int stepNum = queue.poll(); if (stepNum >= n && stepNum <= m) { System.out.print(stepNum + " "); } if (stepNum == 0 || stepNum > m) { continue; } int lastDigit = stepNum % 10; int stepNumA = stepNum * 10 + (lastDigit - 1); int stepNumB = stepNum * 10 + (lastDigit + 1); if (lastDigit == 0) { queue.add(stepNumB); } else if (lastDigit == 9) { queue.add(stepNumA); } else { queue.add(stepNumA); queue.add(stepNumB); } } } public static void main(String[] args) { int n = 0, m = 100; System.out.print("Stepping Numbers between " + n + " and " + m + ": "); displaySteppingNumbers(n, m); } } Python Program
def displaySteppingNumbers(n, m): queue = [] for i in range(1, 10): queue.append(i) while queue: stepNum = queue.pop(0) if stepNum >= n and stepNum <= m: print(stepNum, end=' ') if stepNum == 0 or stepNum > m: continue lastDigit = stepNum % 10 stepNumA = stepNum * 10 + (lastDigit - 1) stepNumB = stepNum * 10 + (lastDigit + 1) if lastDigit == 0: queue.append(stepNumB) elif lastDigit == 9: queue.append(stepNumA) else: queue.append(stepNumA) queue.append(stepNumB) n = 0 m = 100 print("Stepping Numbers between", n, "and", m, ": ", end='') displaySteppingNumbers(n, m)
Q) Problem Statement -:
In an airport, the Airport authority decides to charge a minimum amount to the passengers who are carrying luggage with them. They set a threshold weight value, say, T, if the luggage exceeds the weight threshold you should pay double the base amount. If it is less than or equal to threshold then you have to pay $1.
Function Description:
Complete the weightMachine function in the editor below. It has the following parameter(s):
Parameters:
Name | Type | Description |
N | Integer | number of luggage |
T | Integer | weight of each luggage |
weights[ ] | Integer array | threshold weight |
Returns: The function must return an INTEGER denoting the required amount to be paid.
Constraints:
- 1 <= N <= 10^5
- 1 <= weights[i] <= 10^5
- 1 <= T <= 10^5
Input Format for Custom Testing:
- The first line contains an integer, N, denoting the number of luggage.
- Each line i of the N subsequent lines (where 0 <= i <n) contains an integer describing the weight of ith luggage.
- The next line contains an integer, T, denoting the threshold weight of the boundary wall.
Sample Cases:
- Sample Input 1
4
1
2
3
4
3 - Sample Output 1
5 - Explanation:
Here all weights are less than threshold weight except the luggage with weight 4 (at index 3) so all pays base fare and it pays double fare.
C Program
#include<stdio.h> long int weightMachine(long int N,long int weights[],long int T) { long int amount=0,i; for(i=0;i<N;i++) { amount++; if(weights[i]>T) { amount++; } } return amount; } int main() { long int N,i,T; scanf("%ld",&N); long int weights[N]; for(i=0;i<N;i++) { scanf("%ld",&weights[i]); } scanf("%ld",&T); printf("%ld",weightMachine(N,weights,T)); return 0; } C++ Program
#include <bits/stdc++.h> using namespace std; long int weightMachine(long int N,long int weights[],long int T) { long int amount=0,i; for(i=0;i<N;i++) { amount++; if(weights[i]>T) { amount++; } } return amount; } int main() { long int N,i,T; cin>>N; long int weights[N]; for(i=0;i<N;i++) { cin>>weights[i]; } cin>>T; cout<<weightMachine(N,weights,T); return 0; } Java Program
import java.util.*; class Main { static int weightMachine (int N, int weights[],int T) { int amount = 0, i; for (i = 0; i < N; i++) { amount++; if (weights[i] > T) { amount++; } } return amount; } public static void main (String[]args) { Scanner sc = new Scanner (System.in); int n = sc.nextInt (); int weights[]= new int[n]; for(int i=0; i<n; i++) weights[i] = sc.nextInt(); int t = sc.nextInt (); System.out.println (weightMachine(n, weights, t)); } }
Python Program
def weightMachine(N,weights,T): amount=0 for i in weights: amount+=1 if(i>T): amount+=1 return amount N=int(input()) weights=[] for i in range(N): weights.append(int(input())) T=int(input()) print(weightMachine(N,weights,T))
Q) You are given a list of daily prices of a stock. You can buy a stock on one day and sell it later on another day after the day you bought the stock. You can perform the above operation only once. What is the maximum loss possible?
Example
Prices=[10,4,2,9]
The greatest loss is incurred when you buy at a price of 10 and sell at a price of 2. Return the difference:9.
Example
Price=[1,2,3,4]
The Price went up every day. Return 0.
Sample Input for Custom Testing
STDIN Function
———– ————–
- 7 → Prices [] size n=7
- 1 → prices =[1,8,4,2,10,3,2]
- 8
- 4
- 2
- 10
- 3
- 2
Sample Output
- 8
Explanation
Using zero-based index notation, the correct answer is a[4]-a[6]=10-2=8. There is a greater difference between 10 and 1 but that would imply selling before buying, and short selling is not allowed in this problem.
C++ Program
n=int(input()) arr=[] ans=[0] for i in range(n): arr.append(int(input())) for i in range(n-1): x=min(arr[i+1:])-arr[i] if x<0: ans.append(x) print(-1*min(ans)) Java Program
import java.util.*; class Solution { public static int solve(ArrayList < Integer > list) { int n = list.size(); if (n == 0) return 0; int max = list.get(0); for (int i = 1; i < n; i++) max = Math.max(max, list.get(i)); if (max <= 0) return 0; int maxSum = 0; int sum = 0; for (int i = 0; i < n; i++) { sum = sum + list.get(i); if (sum < 0) sum = 0; maxSum = Math.max(maxSum, sum); } return maxSum; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int arr[] = new int[n]; for (int i = 0; i < n; i++) arr[i] = sc.nextInt(); ArrayList < Integer > list = new ArrayList(); for (int i = n - 2; i >= 0; i--) list.add(arr[i] - arr[i + 1]); int res = solve(list); if (res < 0) System.out.println(0); else System.out.println(res); } }
Q) Problem Statement :
There is a hostel warden in some XYZ hostel. He is very strict with students. He has some set of rules to allow students to let them out.
Students are in random order but warden don’t allow them in that way.
Rule 1- whose initial is a prime value should go out before whose initial is a composite value.
Rule 2- if two students have prime value , a student with less value goes out first
Rule 3- if two students have composite value , a student with greater value goes out first
NOTE:- consider the ASCII value of the initial to find it is prime or composite.
Input format:
The first line of input contains the number of students N
The second line of input contains random order of the students S.
(students at index zero goes out first and students at index N-1 goes last)
Constraints
1<=number of students <=105
33<=ASCII Of Characters<=126
Output Format
The single line of output should contain the required modified order of students to go out.
Sample Input
13
Kkunjkhahorin
Sample Output
akkuronnjihhK
Explanation
For primes: a<k
For Composite: K<h<i<j<n<o<r<u
Adding up logic, the required answer is akkuronnjihhK
C++ Program
#include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; string s;cin>>s; int prime[128]; prime[0]=prime[1]=0; int p=2; for(int i=2;i<128;i++) prime[i]=1; while(p*p<=127) { if(prime[p]) { for(int i=p*p;i<=127;i+=p) prime[i]=0; } p++; } string s1,s2; for(auto i:s) { if(prime[i]) s1+=i; else s2+=i; } sort(s1.begin(),s1.end()); sort(s2.begin(),s2.end()); reverse(s2.begin(),s2.end()); cout<< s1<< s2; }
Java Program
import java.util.Collections; import java.util.Scanner; import java.util.Vector; public class Applicartion22 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = sc.next(); boolean primes[] = new boolean[127]; for (int i = 0; i < 127; i++) { primes[i] = true; } primes[0] = false; primes[1] = false; int p = 2; while (p * p <= 126) { if (primes[p]) { for (int i = p * p; i < 127; i += p) { primes[i] = false; } } p += 1; } Vector < Character > s1 = new Vector < > (); Vector < Character > s2 = new Vector < > (); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (primes[(int) ch]) { s1.add(ch); } else { s2.add(ch); } } Collections.sort(s1); Collections.sort(s2); for (int i = 0; i < s1.size(); i++) { System.out.print(s1.get(i)); } for (int i = s2.size() - 1; i >= 0; i--) { System.out.print(s2.get(i)); } } } Python Program
n = int(input()) s = input() prime = [True] * 127 prime[0] = prime[1] = False p = 2 while p * p <= 126: if prime[p]: for i in range(p * p, 127, p): prime[i] = False p += 1 s1 = [] s2 = [] for i in s: if prime[ord(i)]: s1.append(i) else: s2.append(i) s1.sort() s2.sort(reverse=True) s1.extend(s2) print("".join(s1))
Python Program
Govt Jobs by Qualifications
Education & Vacancies | Salary | Apply Link |
---|---|---|
12th Pass Govt Jobs - 18,000+ Vacancies | Rs. 5,200 - 92,300 | Apply Now |
ITI Pass Jobs - 3,500 Vacancies | Rs. 5,200 - 35,000 | Apply Now |
Any Graduate Jobs - 19,100 Vacancies | Rs. 5,200 - 92,300 | Apply Now |
Central Govt Jobs | Rs. 5,200 - 17,000 | Apply Now |
Bank Jobs - 1,000 Vacancies | Rs. 5,200 - 29,200 | Apply Now |
Diploma Jobs - 9,300 Vacancies | Rs. 5,200 - 35,000 | Apply Now |
BTech/BE Jobs - 18,000 Vacancies | Rs. 15,000 - 1,00,000 | Apply Now |
Data Entry Jobs - 1,300 Vacancies | Rs. 5,200 - 29,200 | Apply Now |
Private Jobs | Rs. 10,000 - 67,700 | Apply Now |