EPAM Latest Coding Questions with Solutions 2023

Epam Systems Off Campus Drive for Junior Engineer | B.E/B.Tech/M.E/M.Tech/MCA/M.Sc(2021/22/23)


About Epam Systems :

EPAM Systems, Inc. ("Effective Programming for America") is an American company that specializes in service development, digital platform engineering, and digital product design, operating out of Newtown.

The EPAM Systems recruitment process usually involves five rounds; the difficulty level ranges from easy to medium. An individual who has good Java programming skills and computer science knowledge can crack the interview.

Here In this blog we Discuss Some EPAM latest coding questions 2022, Epam Coding Question with Solutions, Epam coding questions for junior engineer, Epam Round1 and Round2 Questions with solutions(Updated)


Assessment Parameters:
  • MCQs on OOPS,Data Structures
  • Core JAVA And Coding Challenges Algorithm
  • Object Oriented Programming
The recruitment process for junior Software Engineer is here :
 Round 1 : Java Online Coding Questions and MCQ'S
 Round 2 : Java Online Coding challenge 
 Round 3 : Group Discussions
 Round 4 : Technical Interview 
 Round 5 : HR Interview
  1. Online Coding was hosted on my-anatomy platform. Language was restricted to Java only. This round concentrates on algorithms, data structure, and basic oops concept. There were three questions in the first round in which one was easy, the second moderate and the third question was of advanced level. One needs to solve more than two questions to qualify for the next round.

  2. Onsite Coding Round was a bit tougher, but the cut off was not that high. It depends on the relative performance of other candidates participating. It consisted of 11 MCQ's questions followed by one average and another tough question. This was also taken on my-anatomy.

  3. After qualifying the above round, a Group Discussion was conducted to test your communication and leadership skills. Being a good listener and speaker and showing some leadership quality will make you through this round.

  4. Then came the Technical Interview and the most important one, in which they were just targeting four things Algorithms, Data Structures, Java, Problem, and Puzzle-solving skills. Anyone good in java and competitive coding can manage to qualify for this round.

  5. Hr Round was just a formality round, if one has performed well in the previous round, then this round does not play many roles. Although people were rejected in this round as well. So the only thing they were searching for was the ability to solve the problem with language constraints as Java. This ability can be achieved by being regular at coding competitions and learning as many algorithms and data structures as possible. 

In this article, we will be discussing some of the Epam Coding Questions asked in the previous recruitment tests.


Need More Questions ping me on Instagram : codingsolution75

Epam Coding Questions With Solutions

Epam Question 1 : Game of Profit

You are given the predicate price of XYZ company's share for every minutes Each minutes , you are allowed to either buy one share of XYZ or sell any number of share of XYZ that you own or not make any transaction at all . Your task is to find out the max profit.
Constraints
1 <= T <= 10
1 <= N <= 5*105
All share price are between 1 and 105
Input Format :
The first line contains the number of test cases T. T test cases following consisting of the two lines.
The first line of each test case contains a number of N. The next line contains N integer, denoting the predicated price of shares for the next N minutes
Output Format :
Output T lines, each contains the maximum profit which can be obtained for the corresponding test case.
Sample Input :
3
3
5 3 2
3
1 2 100
4
1 3 1 2
Output
0
197
3
Explanation none
import java.util.Scanner;
public class Main {
  public static void main(String[] args) 
    Scanner sc = new Scanner(System.in);
    int numOfTestCase = sc.nextInt();
    for (int i = 0; i < numOfTestCase; i++) {
      int n = sc.nextInt();
      long profit = 0;
      int[] stockPrice = new int[n];
      for (int j = 0; j < n; j++) 
        stockPrice[j] = sc.nextInt();
      int currMax = Integer.MIN_VALUE;
      for (int j = n - 1; j >= 0; j--) {
        if (currMax > stockPrice[j]) {
          currMax = stockPrice[j];
        }
        profit += (currMax - stockPrice[j]);
      }
      System.out.println(profit);

    }
  }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 2 : Magical Vowels

Katrina has a string "s", consisting of one or more of the following letters:
a,e,i,o and u. We define a magical sub-sequence of s to be a sequence of letter derived from s that contains all five vowels in order. This means a magical sub-sequence will have one or more a's followed by the one or more's followed by one or more i's followed by one or more o's followed by one or more u's For example,
if s = "aeeiooua", the n "aeiou" and "aeeioou" are magical subsequence but "aeio" and "aeeioua" are not
Input Format
Your code should be read input from the given attached file as a string (no line breaks)
Constraints
5 lenght of string s M 5 * 105
String s is composed of English vowels (i.e a,e,i,o,u)
Output Format
You must return an integer denoting the length of the longest magical subsequence in s
Sample input 1 : aeiaaioooaauuuaeiou
Sample Output 1 : 10
import java.util.Arrays;
import java.util.Scanner;

public class LVM {
  static final int NOT_POSSIBLE = -1000000000;
  static int longestSubsequence(String s, char[] c) {
    if (s.length() == 0 || c.length == 0) {
      return 0;
    }
    if (s.length() < c.length) {
      return NOT_POSSIBLE;
    }
    if (s.length() == c.length) {
      for (int i = 0; i < s.length(); i++) {
        if (s.charAt(i) != c[i]) {
          return NOT_POSSIBLE;
        }
      }
      return s.length();
    }
    if (s.charAt(0) < c[0]) {
      return longestSubsequence(s.substring(1), c);
    } else if (s.charAt(0) == c[0]) {
      return Math.max(Math.max((1 + longestSubsequence(s.substring(1), Arrays.copyOfRange(c, 1, c.length))),     
          (1 + longestSubsequence(s.substring(1), c))), (longestSubsequence(s.substring(1), c)));
    } else {
      return longestSubsequence(s.substring(1), c);
    }
  }
  public static void main(String[] args) 
    char[] chars = { 'a', 'e', 'i', 'o', 'u' };
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    System.out.println(longestSubsequence(s, chars));
  }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Question 3 :Student for Viva

The season of the vivas are ON!! There are a number of student in a class.Each class of the students has to give viva, but there is one rule teacher have decided to choose the student whose turn it will to give viva, The teacher is picking certain role numbers form the list of the students. On each day, student with high role numbers than his left student's role number will be picked to give viva on that day. Determine the number of days after which no student from the initial picking is remaining to give viva, i.e the time after which there is no student with higher roll number on his left.
Example
roll_numbers=[3,6,7,5] //roll number of student randomly picked initially amongst all students

Use a 1-indexed array. On day 1, roll number 6 and 7 will be picked to give viva leaving roll_numbers'=[3,2,5]. On day 2, roll number 5 will be picked for viva leaving roll_numbers'=[3,2]. There is no student with a higher roll number than one to its left, so that batch will be over with the viva and will be ready to enjoy the vacations.
Input Format
The first line contains an integer an integer n, the size of the array roll_number.
The next lines contains n line-separated integer roll_number[i].
Constraints
1<= n <=105
1<= roll_number[i] <= 109
Sample Input
7
6 5 8 4 7 10 9
Output 2
Explanation
Initially there roll number will be picked from all list of student.
roll_numbers={6,5,8,4,7,10,9}
After the 1st day 4 student will remain for viva, since student with roll number 8 7 10 will picked
roll_number={6,5,4,9}
One the 2nd day, 3 student will be remaining for viva, since student with roll number 9 will be picked for viva.
roll_number={6,5,4}
All the student will be picked up after the 2nd day.
import java.util.ArrayList;
import java.util.Scanner;
public class StudentViva {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Integer> al = new ArrayList<>();
    for(int i=0; i<n; i++) {
      al.add(sc.nextInt());
    }
    int c = 0;
    while(true) {
      boolean flag = true;
      for(int i=1; i<al.size()-1; i++) {
        if(al.get(i) > al.get(i-1) ) {
          al.remove(i);
          flag = false;
        }
      }
      if(flag) {
        break;
      }else {
        c++;
      }
    }
    System.out.println(c);
  }
}   
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Question 4:Oxygen Cylinders Management

You are the given a list of covid patients where patient[i] is the required by the ith patient, and there are enough cylinders where each cylinder contains a limited amount of oxygen. Each cylinder can serve at most two patients at the same time, provided the array of the oxygen required by the patients and cylinder capacity.
Return the minimum quantity of cylinders to serve all patients.
Input
The fist line contains an integer n which gives the size of patients the.
The second line contains an integer 1 which gives the limit or capacity of the cylinder.
The next n lines contains an integer which gives the amount of oxygen required by a particular patient.
Output:
Print a single integer that gives the number of cylinder required to fulfill all requirements. Constraints:
1 <= n <= 10000
1 <= patients[i] <= limit <= 3 * 10000
Input: 2
1
1
2
Sample output:
1
Explanation: 1 cylinder {1,2}

Solution:

import java.util.Scanner;
public class Main{
     static int numOxygenCylinder(int[] oxyegen, int limit){
         int sum =0;
         for(int i : oxyegen){
            sum+=i;
         }
         if(sum%limit == 0) return sum/limit;
         else return (sum/limit)+1;
     }
     public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
         int n = sc.nextInt();
         int limit = sc.nextInt();
         
         int[] oxygen = new int[n];
         for(int i=0; i<n; i++) oxygen[i] = sc.nextInt();
         System.out.println(numOxygenCylinder(oxygen, limit));
     }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 5 : Count the Number of vowels Occurring in all the sub-string of given String

Given a string of length N of lowercase character contains 0 or more vowels, the task is to find the count of vowels occurred in all the sub-string of the given string.
Thomas is always curious about vowels so he decided to know how many vowels can be found from all possible sub-string made from a particular string without jumbling the character.
Sample Input:
abc
Sample Output:
3
Explanation:
The given string "abc" contains only one vowels ='a'
Substring of "abc" are = {"a", "b", "c" . "ab", "bc", "abc"}
Hence, the sum of occurrence of the vowels in these string = 3. ('a' occurred 3 times)
import java.util.ArrayList;
import java.util.Scanner;
public class CountVowelsSubstring {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count =0;
		ArrayList<String> list = new ArrayList<>();
		String s = sc.nextLine();
		int len = s.length();
		s = s.toLowerCase();
		for (int i = 0; i < len; i++) {
		  for (int j = i + 1; j <= len; j++) {
			String temp = s.substring(i, j);
			  if (!list.contains(temp)) {
				list.add(temp);
			  }
		   }
		   count = 0;
		   for (String str : list) {
			 for (int k = 0; k < str.length(); k++) {
				char ch = str.charAt(k);
				if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {         
				  count++;
				}
		     }
		   }
		}
		System.out.println(count);
	}
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Epam Question 6 :Owner of shop and Smart Kiddo

Solution

import java.util.Scanner;
public class NumToString {
	public static final String[] units = { "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
			"Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen",
			"Nineteen" };
	public static final String[] tens = { "",
			"", 
			"Twenty", 
			"Thirty", 
			"Forty", 
			"Fifty", 
			"Sixty", 
			"Seventy", 
			"Eighty", 
			"Ninety" 
	};
	public static String convert(final int n) {
		if (n < 0) {
			return "minus " + convert(-n);
		}
		if (n< 20) {
			return units[n];
		}
		if (n <100) {
			return tens[n / 10] + ((n % 10 != 0) ? " " : "") + units[n % 10];
		}
		if (n < 1000) {
			return units[n / 100] + " Hundred" + ((n % 100 != 0) ? " " : "") + convert(n % 100);
		}
		if (n &lh; 1000000) {
			return convert(n / 1000) + " Thousand" + ((n % 1000 != 0) ? " " : "") + convert(n % 1000);
		}
		if (n &lh; 1000000000) {
			return convert(n / 1000000) + " Million" + ((n % 1000000 != 0) ? " " : "") + convert(n % 1000000);
		}
		return convert(n / 1000000000) + " Billion" + ((n % 1000000000 != 0) ? " " : "") + convert(n % 1000000000);     
	}
	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println(convert(n));
	}
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 7:Booking Range

Virat is looking to book hotel rooms for an incoming delegation of engineers.she is allowed to spend anywhere between B Rupees and C Rupees(Both Inclusive). She need to book rooms consecutively as delegates would prefer to stay as close as possible.
Virat as been given the pricing of the rooms in the form of a array (A). You need to help virat to find the total no of options available to book like this in the given range.
Note: There is no restriction in no of rooms he can book. (Min 1 or Max Size of the array)
Input Format:
First line contains 3 integer N,B,c where N is size of array.
Second line contains N Integer denoting the price of t= each rooms available.
Output Format: Total No of possible option available for the books the rooms.
Constraints:
1 <= N,B,C <= 106
Sample Input 0
5 6 8
10 5 1 0 2
Output 0
3
Explanation:
[5,1],[5,1,0],[5,1,0,1] are only 3 consecutive options available within the price of sum range.

Solution

import java.util.HashMap;
import java.util.Scanner;

public class RangBooking {
  static int findSubarraySum(int arr[], int n, int sum) {
    HashMap<Integer, Integer> prevSum = new HashMap<>();
    int res = 0;
    int currsum = 0;
    for (int i = 0; i < n; i++) {
      currsum += arr[i];
      if (currsum == sum)
        res++;
      if (prevSum.containsKey(currsum - sum))
        res += prevSum.get(currsum - sum);
      Integer count = prevSum.get(currsum);
      if (count == null)
        prevSum.put(currsum, 1);
      else
        prevSum.put(currsum, count + 1);
    }
    return res;
  }
  public static void main(String[] args) {      
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int[] arr = new int[N];
    for (int i = 0; i < N; i++) {
      arr[i] = sc.nextInt();
    }
    int sum = 0;
    for (int i = B; i <= C; i++) {
      sum += findSubarraySum(arr, N, i);
    }
    System.out.println(sum);
  }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 8: Binary Tree Combinations

Given the elements of binary tree in an array format. You need to return the number of possible ways to reorder the elements in the array such that the binary tree similar to the order one.
Sample Input 1:
4 3 5
Sample Output 1:
1
Explanation:
        4
     /      \
   3        5
[4,3,5] is only possible ways to reorder such that the binary tree doesn't change.
Sample Input 2:
1 2 3
Sample Output 2:
0
Explanation :

1
   \
     2
        \ 
           3
No Possible ways to reorder.

Solution

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Solutions {
  public static int numOfWays(int[] nums) {
    int length = nums.length, MOD = 1000000007;
    long[][] DP = new long[length + 1][length + 1];
    for (int j = 0; j <= length; j++) {
      DP[0][j] = 1;
    }
    for (int i = 0; i <= length; i++) {
      DP[i][0] = 1;
    }
    for (int i = 1; i <= length; i++) {
      for (int j = 1; j <= length; j++) {
        DP[i][j] = ((DP[i][j - 1] + DP[i - 1][j]) % MOD);
      }
    }
    return ((int) getNumberOfWays(nums, DP) - 1);
  }
  private static long getNumberOfWays(int[] nums, long[][] DP) {
    int length = nums.length, m = 0, n = 0, MOD = 1000000007;
    if (length == 0) {
      return 1;
    }
    for (int i = 2; i <= length; i++) {
      if (nums[i - 1] < nums[0]) {
        m++;
      } else {
        n++;
      }
    }
    int[] leftNodes = new int[m];
    int[] rightNodes = new int[n];
    m = 0;
    n = 0;
    for (int i = 2; i <= length; i++) {
      if (nums[i - 1] < nums[0]) {
        leftNodes[m++] = nums[i - 1];
      } else {
        rightNodes[n++] = nums[i - 1];
      }
    }
    return (((DP[m][n] * getNumberOfWays(leftNodes, DP) % MOD) * getNumberOfWays(rightNodes, DP)) % MOD);
  }
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s = br.readLine();
    String[] arr = s.split(" ");
    int[] ar = new int[arr.length];
    for (int i = 0; i < arr.length; i++) {
      ar[i] = Integer.parseInt(arr[i]);
    }
    System.out.println(numOfWays(ar));
  }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 9: Custom sorting Candidate Object

Given a class name Candidate Which implements Comparable interface. In candidate class there
fields Present.
private String name
private String marks
and you have given a list of Object of type Candidate Which is unsorted. You need to
initialize the constructor and overwrite the compare to method so that after using
collections.sort(list) should be sorted in ascending order based on marks. (refer
sample INPUT OUTPUT for more clarity) and complete the incomplete code snipped .

class Candidate Implements Comparable<Candidate>{
private String name;
private String marks;
public Number(String name, int marks){
//Write you code here
}
@Override
public int compareTo(Candidate candidate){
//write your code here
}
//create getter for both fields
//getter method name must be getName(), getMarks()
//Write your code here...
}

Constraints:
2<=t <= 10^5
name: contains any alphabats letter (String)
1<=makrs <=10^9

Input Format:
First line contains t size of list
Next t line conatains name and marks seprete with space

SAMPLE INPUT
2
Ram 20
Shyam 10

SAMPLE OUTPUT
Shyam 10
Ram 20
class Candidate implements Comparable<Candidate>  {
    private String name ;
    private int marks;
	public Candidate(String name, int makrs) {
		this.name = name;
		this.marks = makrs;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getMarks() {
		return marks;
	}
	public void setMarks(int marks) {
		this.marks = marks;
	}
	@Override
	public int compareTo(Candidate candidate) {
	   return this.marks - candidate.marks;
	}
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 10 : Oop's Custom IntegerList

Integarlist is one kind of list which contain only integer in value. you are Oops concept
expert so you think to create own custom integer list which include add method toString method.
for creating integer list you are searching on www search engine and you found the code snippet
which is useful for your integer list but in the code structure and method are not complete.
so you task to complete the uncompleted constructor method.code snippet is given below :
-add method : a method to add integer to the list
-toString method that return the content of the list with indices.

public class IntegerList {
private int list[];
private int elementIndex = 0;
//Constructor -- create an integer list of give size
public IntegerList(int size) {
//write your code here...
}
public void add(int value) {
//write your code here...
}
public String toString() {
//write your code here..
}
}
public class IntegerList {
	private int list[];
	private int elementIndex = 0;

	public IntegerList(int size) {
		this.list = new int[size];
	}

	public void add(int value) {
		if (elementIndex >= list.length)
			System.out.println("Can't add, list is full");
		else
		list[elementIndex++]  = value;
	}
	public String toString() {
		String ans = "";
		for (int Index = 0; Index < list.length; Index++) {
               ans+=Index+":"+list[Index]+"\n";
		}
		return ans;
	}

If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 11: RainWater Preservation

Sri ,one day while traveling back to home from office during a rainy season,noticed that
rainwater is not preserved and use to rather left for wasted. So he wanted to build a system
where the rainwater can be trapped, and the system should have ability to compute how much rain
water is trapped.
Let's assume their a bunch of bars [grey] show the below elevation map. Each bar width is 1.
Rainwater is trapped between the grey bars compute. How much water it can be trap after raining?
The elevation map is represent by array[0,1,0,2,1,0,1,3,2,1,2,1].
In this case, 6 unit of rainwater are being trapped.

Explanation:
Count only the blue section as each bar width contains "1" value
Count 1+1+2+1+1=6
Sample Input :
12
0,1,0,2,1,0,1,3,2,1,2,1

Sample Output
6
class Solution {
   public int trap(int[] height) {
        int[] left = new int[height.length];
        int[] right = new int[height.length];
        left[0] = height[0];
        right[height.length-1] = height[height.length-1];
        
        for(int i=1; i<height.length; i++){
          left[i] = Math.max(left[i-1], height[i]);
        }
        for(int i=height.length-2; i>=0; i--){
          right[i] = Math.max(right[i+1], height[i]);
        }
        
        int max =0;
        for(int i=0; i<height.length; i++){
            max += Math.min(left[i],right[i])-height[i];
        }
        
        return max;
    }
}

Epam Question 12: Rangoli Design

import java.util.*;
public class HelloWorld {
    public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int test=sc.nextInt();
    for(int i=0;i<test;i++){
    int[] arr=new int[3];
            arr[0]=sc.nextInt();
            arr[1]=sc.nextInt();
            arr[2]=sc.nextInt();
        Arrays.sort(arr);
    if((arr[2]-1)<=arr[1]){
        System.out.println("Possible");
    }else if((arr[2]-1)<=(arr[1]+arr[0])){
            System.out.println("Possible");
    }else{
        System.out.println("Impossible");
    }
    }
    }
}

Epam Question 13: Binary Jump

import java.util.Scanner;
public class Solution {
   public static int powerJump(String s) {
      int count = 1;
      int maxx = Integer.MIN_VALUE;
      char ch = s.charAt(s.length() - 1);
      for (int i = 0; i < s.length(); i++) {
	 if (s.charAt(i) == ch) {
	   if (count > maxx) {
	      maxx = count;
	   }
	   count = 1;
	}else
	  count++;
	}
	return maxx;
    }
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String st = sc.nextLine();
	System.out.println(powerJump(st));
    }
}

Epam Question 14: Solving Mystery

public static long getMystery(int[] arr, int l, int r, int sum) {
	   long ans = 0;
	   for (int i = 1; i < arr.length; i++) {
		 for (int j = 0; j < i; j++) {
		   if (arr[i] > arr[j]) {
			 ans += arr[j];
		   }
		 }
	   }
	   return ans;
	}

Epam Question 15 : Student Elevation Criteria

class RDStudent extends Person {
	private int[] testScore;

	public RDStudent(String firstName, String lastName, int id, int[] testScore) {
		super(firstName, lastName, id);
		this.testScore = testScore;
	}

	public char calculateGrade() {
		int total = 0;
		for (int i = 0; i < testScore.length; i++) {
			total += testScore[i];
		}
		if (total >= 80 && total < 90) {
			return 'E';
		} else if (total >= 70 && total < 80) {
			return 'A';
		} else if (total >= 55 && total < 70) {
			return 'P';
		} else if (total >= 40 &&total <= 100) {
			return 'D';
		} else
			return 'T';
	}
}

class Person {
	protected String firstName;
	protected String lastName;
	protected int empIDNumber;

	public Person(String firstname, String lastName, int empIDNumber) {
		this.firstName = firstname;
		this.lastName = lastName;
		this.empIDNumber = empIDNumber;
	}
	public void printPerson() {
		System.out.println(
				"Name " + lastName + ", "+ firstName + "\nEmpID "+ empIDNumber
				);
	}
}

Epam Question 16 :Delete Backups after Kth Run

Samuel is a file Backup Expert in an audit firm. He is responsible to create backup for all transaction
files stored in the internal file system. John is a new intern in the file backup team and works
along with Samual in the fle backup activity. After doing the file backup activity for couple of days
Jonh realized that unnecessary backups are created which are never used by the system and proposed
a solutions to samuael to delete backups after kth copy is created Samuel liked the proposal and have
asked John to write a code demonstrating how to this logic will work.

Given the file ids of the original fils whose backup is stored in the file System.
Then delete the additional backups of the original; files id already processed for k times.

Input Format:
The first line contains maxixmu backups allowed values for any file
Next line contains a comma separated positive integer value that represent the files ids.

Output Format
Print the result in the given format.
This is multiple output.

First Line should be contains the comma separated files ids whose backup were restored. Ensure
the original order is maintained.

The next line should contain the comma separated file ids in ascending order whose backup were deleted.

Constraints
1 <= K <= 300
1 <= files id <= 1000
1 <= size of the id comma represented array <= 1000

Sample Input:
2
1,3,2,2,1,2,3,1
Sample Output:
1,3,2,2,1,3
1,2

Explanation:
The backups of the files ids 1,2 were deleted because there were more than 2 backups found in the
file system.
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class KthBackUp {
	public static void proccessAndDeletedAdditionBackups(int n, String filed) {
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		String[] list = filed.split(",");
		String file = "";
		for (int i = 0; i < list.length; i++) {
			int item = Integer.parseInt(list[i]);
			if (map.containsKey(item)) {
				map.put(item, map.get(item) + 1);
				if(map.get(item) <= n) {
					file+=item+",";
				}
			} else {
				map.put(item, 1);
				if(map.get(item) < n) file+=item+",";
			}	
		}
		// System.out.println(map);

		String deleted = "";
		for (Entry<Integer, Integer> mp : map.entrySet()) {
			if (mp.getValue() > n) {
				deleted += (mp.getKey() + ",");
			} 
		}
		System.out.println(file.substring(0, file.length() - 1));
		System.out.println(deleted.substring(0, deleted.length() - 1));

	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		String filed = sc.nextLine();
		proccessAndDeletedAdditionBackups(n, filed);
	}

}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 17 : Fix the palindrome login

You are given a function which checks if the string is a palindrome is a palindrome or not. A string
is called a palindrome if it reads the same from the both ends. it returns 1 if string is a palindrome
else 0. However this code contains some errors identify the error and correct them.

Function description
Complete the check Palindrome function in the editor below it has the following parameters.
Name : str
Type : String
Description The given string to check
Return : The function must return an integer denoting the 1 if it is palindrome else 0

Constraints :
1 <= len(str) <= 10^4

Input format for debugging
The first line contains a string, str, denoting the string.
Sample Test Cases
Input
a
Output
1
Explanation
A single letter is a palindrome

Input
zyx
Output
0
Explanation
The string is not a palindrome

Input
abcba
Output
1
Explanation
The string is a palindrome
import java.util.Scanner;

public class Palindrom {

	public static int checkPalindrom(String str) {
      return str.equals( new StringBuilder(str).reverse().toString()) ? 1 : 0;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		System.out.println(checkPalindrom(str));
	}

}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 18 : Doug's Difference

Doug's was doing him math homework with two of his friend at one point they all got bored but Doug's had
an idea to pass the time in an interesting way he decided to play game of difference such that given
sequences of the integers a, a triplet(a[i], a[j], a[k]) is beautiful if:

1) i < j < k
2) a[j] - a[i] = a[k] - a[j] = d

Given an increasing sequence of the integers and the value of d, count the number of beautiful triplet
in the sequence.

Function Description
Complete the beautiful Triples function in the editor below.
beautiful Triplets has the following parameters:
int d : the value to match
int arr[n]: the sequence, sorted ascending

Return
int:the number of beautiful triplets

Input Format
This first line contains 2 space-separated integers n and d the length of the sequence
and the beautiful difference. The second line contains n space-separated integer ar[i].
Constraints : 1 <= n <= 10^4
1 <= d <= 20
0 <= arr[i] <= 2 * 10^4
arr[i] > arr[i-1]

Sample Input
7 3
1 2 4 5 7 8 10

Sample Output
3

Sample Input
10 3
1 6 7 7 8 10 12 13 14 19

Sample Output
2
import java.util.Scanner;

public class DougDifference {
    public static int beautifulTripplet(int n, int[] arr, int d) {
		int c = 0;
		for (int i = 0; i < n - 2; i++) 
		  for (int j = i + 1; j < n - 1; j++) 
			 for (int k = j + 1; k < n; k++) 
				if (((i < j) && (j < k)) && ((arr[j] - arr[i] == d) && (arr[k] - arr[j] == d)))
					c++;
		return c;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int d = sc.nextInt();
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}		
		System.out.println(beautifulTripplet(n, arr, d));
	}
}

If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 19 : Find the index of extended String

import java.util.Scanner;

public class ExtendefdString {
	public static char findIndex(String str, int k) {
		String ex = "";
		for(char ch : str.toCharArray()) {
			if(ch >='0' && ch<='9') {
				for(int i=0;  i<Integer.parseInt(String.valueOf(ch))-1; i++)
					ex += ex;
			}
			if((ch >='A' && ch <= 'Z') || (ch>='a' && ch  <= 'z'))
				ex+=String.valueOf(ch);
		}
		//System.out.println(ex);
		return ex.charAt(k-1);
	}
	public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  String s = sc.nextLine();
	  int k = sc.nextInt();
	  
	  System.out.println(findIndex(s,k));
	}
}

Epam Question 20 : String formatted

Allow the function format(str) , str is a string and return the string's lengthiest format.
A format for this challenges will be defined as : if at least 2 or more adjacent alphabets within the strong recurse at - least twines
For example "aabecaa" contains the format aa whereas "abbbacc" does not contains any format

Your Program should return yes/no pattern/null.

so if Str is "aabejiabkfabed" then the output should be yes abe.
if Str is "12345" then output should be return no null.

Sample Test Cases :

Input :
da2kr32a2
Output
yes a2
Input
sskfssbbb9bbb
Output
yes bbb
import java.util.Scanner;

public class Solution {
	public static String format(String str) {
		String ptrn = "";
		int pCount = 0;

		for (int i = 0; i < str.length() - 1; i++) {
			for (int j = i - 1; j < str.length(); j++) {
				String sstr = str.substring(i, j + 1);
				pCount = 1;

				for (int k = 0; k < str.length() - sstr.length() + 1; k++) {
					if (k == i)
						continue;
					if (sstr.equals(str.substring(k, k + sstr.length()))) {
						pCount++;
					}
				}
				if (pCount >= 2 &&rn == "" || ptrn.length() <r.length())) {
					ptrn = sstr;
				}
			}
		}
		return ptrn != "" ? "yes " + ptrn : "no null";
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		System.out.println(format(str));
	}
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 21 : Maximum Safe Square Area

public class MaximumSafeSquareArea {

	public static int getMaximumSafeSquareArea(int[][] matrix) {
		int i,j;
		int r = matrix.length ;
		int c = matrix[0].length;
		int [][] dp  = new int[r][c];
		
		int maxS, maxI, maxJ;
		
		for(i=0; i<r; i++) 
			dp[i][0] = matrix[i][0];
		for(j=0; j<r; j++) 
			dp[i][0] = matrix[i][0];
		
		for(i =0; i<r; i++) {
			for(j=1; j<c; j++) {
				if(matrix[i][j] == 1) {
					dp[i][j] = Math.min(dp[i][j-1], Math.min(dp[i-1][j],dp[i-1][j-1]))+1;
				}else {
					dp[i][j]=0;
				}
			}
		}
		maxS = dp[0][0];
		maxI = 0;
		maxJ = 0;
		for(i=0; i<r; i++) {
			for(j=0; j<c; j++) {
				if(maxS < dp[i][j]) {
					maxS = dp[i][j];
					maxI = i;
					maxJ = j;
				}
			}
		}
		int ans =0;
		for(i= maxI ; i>maxI - maxS; i++) {
			for(j = maxJ; j<maxJ-maxS; j--) {
				ans+=1;
			}
		}
		return ans;
	}
	
}

Epam Question 22 : Palindrome Prefix

A Special palindrome is a palindrome of size N which contains most K distinct character such that any prefix of size between and N-1 is not a palindrome.
For example abba is a special palindrome with N=4 and K=2 ababa is not a special palindrome because aba is a palindrome its a prefix of ababa.
Task
Count the number of special palindromes.
Example
Assumptions
N = 3
k = 3
Approach
All possible special palindromes are aba, aca,bab,bcb,cac and cbc
Hence the answers is 6.
Input
3
3
Output
6

public class Main{
   public static long prefix_Palindrom(int N,int K){
        int M  = 1000000000+9;
        long[] dp = new long[N+1];
        dp[1] = K;
       
        for(int i=2; i<=N; i++){
             if(i%2 == 1){
                 dp[i] = ((K * dp[i-1]) % M - dp[(i+1)/2] + M )%M;
             }else{
                 dp[i] = dp[i-1];
             }
        }
        return dp[N];
    
    }
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();

      System.out.println(prefix_Palindrom(N,K));
   }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Epam Question 23 : Hotel Wardon

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.
Input
13
Kkunjkhahorin
Output
akkuronnjihhK
import java.util.*;
class Main{
    public static void sortStudents(int n, String students) {
    // Create two lists for prime and composite students
    List<Character> prime = new ArrayList<>();
    List<Character> composite = new ArrayList<>();

    // Iterate through the input string and separate students into prime and composite lists
    for (int i = 0; i < n; i++) {
        char initial = students.charAt(i);
        int asciiValue = (int) initial;

        // Check if the initial is prime or composite
        boolean isPrime = true;
        for (int j = 2; j <= asciiValue / 2; j++) {
            if (asciiValue % j == 0) {
                isPrime = false;
                break;
            }
        }

        // Add the student to the appropriate list
        if (isPrime) {
            prime.add(initial);
        } else {
            composite.add(initial);
        }
    }

    // Sort the prime and composite lists according to the rules
    prime.sort((a, b) -> a - b);
    composite.sort((a, b) -> b - a);

    // Print the final list of students in the correct order
    for (char student : prime) {
        System.out.print(student);
    }
    for (char student : composite) {
        System.out.print(student);
    }
}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();sc.nextLine();
        String student = sc.nextLine();
        sortStudents(n, student);
    }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Question 24 : Coming Soon

Comments

  1. Epam round 2 coding questions and answers

    ReplyDelete
  2. Please help me for tomorrow exam

    ReplyDelete
  3. Today at 6PM I am having EPAM round 2 exam please help🙏🙏

    ReplyDelete
  4. I have epam exam tomorrow anybody please help me

    ReplyDelete
  5. I have a epam exam tomorrow please help me

    ReplyDelete
  6. I have epam exam tomorrow please help me.

    ReplyDelete
    Replies
    1. Help me for 3rd question of vacation planner

      Delete
  7. I have a epam exam tomorrow please help me

    ReplyDelete
  8. I have exam tomorrow can anybody helpme please

    ReplyDelete
  9. I have a epam exam tomorrow please help me

    ReplyDelete
  10. tommorow is my epam company coding round exam please help me

    ReplyDelete
  11. Tommorow is epam coding round exam can anyone help me pl....

    ReplyDelete
  12. I have exam now can you help me out epam

    ReplyDelete
  13. Today 2:30 having coding exam plz help me

    ReplyDelete
  14. I have my EPAM exam from today 3:30PM can you help me

    ReplyDelete
  15. please help me i have an exam now

    ReplyDelete
  16. sir pls send the code of search for food by Charlie code

    ReplyDelete
  17. Today 4PM I have an Technical Round 2 Test
    Can I get Any Help ?

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. Brother, I am having my EPAM exam after an hour, please help Me!
    I shall be grateful!
    Please, post any media through which I can contact you🙏🏻

    ReplyDelete

Post a Comment

If you any doubts, please let me know Telegram Id: @Coding_Helperr
Instagram Id : codingsolution75

More Related

For Any Help Related to coding exams follow me on Instagram : codingsolution75

Popular Posts

WIPRO Latest Coding Questions with Solutions : 2023

MindTree Latest Coding Questions with Solutions

Fresco Play Hands-on Latest Solutions

TCS Digital Exam | DCA | Direct Capability Assessment

TCS Wings 1 All Prerequisite

Infosys | InfytTq | Infosys Certification Exam Latest Coding Questions with Solutions

RAKUTEN Latest Coding Questions with Solutions

Cognizant

TypeScript Complete Course With Completed Hands-on