So today we will discuss Epam coding questions with Answers and also Epam Programming Questions. But, before discussing the questions we’ll make you know about Epam Company. So,

What is Epam?

Epam Systems Inc is a multinational American company that specializes in service development, digital product design, etc. It is one of the largest manufacturers of custom software. The headquarters of this company is located in Newton, Pennsylvania. Epam Systems is now expanded into more than 40 countries. This company was established in the year 1993 by Arkadiy Dobkin and Leo Lozner. Now Epam has also entered the Indian market so they’re hiring more and more Indian students. They are conducting off-campus drives to hire employees.

Currently, they have their offices only in Bangalore and Hyderabad city. Therefore the hirings which they conduct is for These two cities.

Epam Eligibility Criteria

Before applying for the Junior Software Engineer position at Epam you must pass the below eligibility criteria:

  • Candidate should be graduated and hold the degree of B.E, B.Tech, M.E, M.Tech, or MCA.
  • The stream of the graduation should be CSE, ECE, IT, and other computer-related streams only.
  • You should be passed with an overall score of more than 60% or 6.0 CGPA in graduation, 10th as well as in 12th.
  • The candidate should not have active or current backlogs.

Epam Coding Questions

TestCoding
No of Questions Asked3
Difficulty LevelMedium or High
Salary6 lpa
Duration150 Minutes
RoundFirst

The coding questions are asked in the first round of the Epam Selection process. In the first round, 3 coding questions are asked based on Java which candidates have to solve within the time of 150 minutes. The questions asked in the coding round will be based on only Java language. During the exam, candidates are not allowed to leave their seats and the webcam is mandatory in the first round.

The first question will be for 20 marks, the second for 30 marks. Similarly, the third question will be for 50 marks. Higher the marks for the question, higher the difficulty level of that question. The candidates who score better in this round will be qualified for the next round. So, practice more and more repeated epam coding questions.

Things to Take Care of While Appearing for Epam Coding Test

  • The webcam is compulsory for the coding test. The Candidates should also check the internet connection prior to the exam. Also, check whether the webcam is working properly or not.
  • Please make sure that the stuff which will be needed while the exam such as pen, paper, pencil, and water bottle keep it ready before the exam.
  • The candidate is not allowed to move or leave the chair before the test ends. The exam software will give only 2 or 3 warnings if the camera is covered or your face is not visible. If you do the same thing after 3 warnings then the test will be automatically canceled.
  • Keep in mind that the code which you’ll write is checked by the plagiarism checker. If the checker finds that you’re copying the code from another device or from other platforms then you’ll be disqualified in the first round itself.

Now let’s discuss the previously asked Epam Coding Questions with Answers.

Epam Coding Questions With Answers

Game of Profit

You’re given the predicate price of XYZ company’s share for every minute. Each minute, you’re allowed to either buy one share of XYZ or sell any number of shares 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*10^5

All share price are between 1 and 10^5

Input Format:

The first line contains the number of test cases T. T test cases following consisting of two lines.

The first line of each test case contains a number of N. The next line contains N integers, 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

Program:

//Learnprogramo - programming made simple
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);
    }
  }
}

Magical Vowels

Katrina has a string ‘s’ consisting of one or more of the following letters: a, e, i, o, u. We define a magical subsequence of letters derived from s that contains all five vowels in order. This means a magical subsequence 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”, then “aeiou” and “aeeioou” are magical subsequences 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 length of string s M 5*105

String s is composed of English vowels (a, e, i, o, u)

Output Format:

You must return an integer denoting the length of the longest magical subsequence in s

Sample Input:

aeiaaioooaauuuaeiou

Sample Output:

10

Program:

//Learnprogramo - programming made simple
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));
  }
}

Student for Viva

The seasons of the vivas are ON!! There are a number of students in a class. Each class of students has to give viva, but there is one rule teacher has decided to choose the student whose turn it will give viva. The teacher is picking a certain role number from the list of the students. On each day, students with a high role number than his left student 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 a higher roll number on his left.

Example:

roll_numbers = [3, 6, 7, 5] (roll numbers of the students randomly picked initially amongst all students)

Use a 1-indexed array. On day 1, roll numbers 6 and 7 will be picked to give viva leaving roll_numbers = [3, 2, 5]. On day 2, roll numbers 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 n, the size of the array roll_number.

The next lines contains n line-separated integer roll_number[i].

Constraints:

1 <= n <- 10^5

1 <= roll_number[i] <= 10^9

Sample Input:

7

6 5 8 4 7 10 9

Output:

2

Program:

//learnprogramo - programming made simple
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);
  }
}   

Oxygen Cylinders Management

You’ve 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 first line contains an integer n which gives the size of patients.

The second line contains an integer 1 which gives the limit or capacity of the cylinder.

Now, the next n lines contain an integer that gives the amount of oxygen required to fulfill all requirements.

Constraints:

1 <= n <=10000

1 <= patients[i] <= limit <=3 * 10000

Sample Input:

2

1

1

2

Sample Output:

1

Program:

//Learnprogramo - programming made simple
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));
     }
}

Counting the Vowels

Given a string of length N of lowercase character contains 0 or more vowels, the task is to find the count of vowels that occurred in all the substring of the given string.

Thomas is always curious about vowels so he decided to know how many vowels can be found from all possible substrings 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’. So, the substring of “abc” are = {“a”, “b”, “c”, “ab”, “bc”, “abc”}. Hence the sum of occurrence of the vowels in these string =3 (a occured 3 times)

Program:

//Learnprogramo - programming made simple
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);
	}
}

Booking Range

Virat is looking to book hotel rooms for an upcoming delegation of engineers. He is allowed to spend anywhere between B Rupees and C Rupees(Both Inclusive). He needs to book rooms consecutively as delegates would prefer to stay as close as possible. Virat has been given the pricing of the rooms in the form of an 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 on no of rooms he can book. (Min 1 or Max Size of the array)

Input Format:

First-line contains 3 integers N, B, and C where N is the size of the array.

The second line contains an N integer denoting the price of t = each room available.

Output Format:

Total No of possible options available for booking the room.

Constraint:

1 <= N, B, C <= 10^6

Sample Input:

5 6 8

10 5 1 0 2

Sample Output:

3

Program:

//Learnprogramo - programming made simple
import java.util.HashMap;
import java.util.Scanner;
public class RoomBooking {
  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);
  }
}

Owner of Shop and Smart Kiddo

Program:

//Learnprogramo - programming made simple
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));
	}
}

BinaryTree 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 is similar to the order one.

Sample Input 1:

4 3 5

Sample Output 1:

1

Sample Input 2:

1 2 3

Sample Output 2:

0

Program:

//Learnprogramo - programming made simple
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));
  }
}

Custom Sorting Candidate Object

Given a class name Candidate which implements the comparable interface. In candidate class fields which are present are:

private String name;

private String marks;

And you’ve given a list of objects of type candidate which is unsorted. You need to initialize the constructor and overwrite the compareTo method so that after using collections.sort(list) should be sorted in ascending order based on marks. refer sample INPUT-OUTPUT for more clarity. Also, complete the incomplete code snippet.

Constraints:

2 <= t <= 10^5

name: contains any alphabet letters (String)

1 <= marks <= 10^9

Input Format:

The first line contains t size of the list.

The next t line contains the name and the marks separated with space.

Sample INPUT:

2

Ram 20

Shyam 10

Sample OUTPUT:

Shyam 10

Ram 20

Program:

//Learnprogramo - programming made simple
//Incomplete Code:
class Candidate Implements Comparable<Candidate>{
  private String name;
  private String marks;
  
  public Number(String name, int marks){
    //write your 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...
}
//Complete Code
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;
	}
}

OOPs Custom IntegerList

IntegerList is one kind of list that contains only integer values. You’re an OOPs concept expert so you think to create your own custom integer list which includes adding the method toString method for creating an integer list. You’re searching on the www search engine and you found the code snippet which is useful for your integer list but the code structure and methods are incomplete. So, your task is to complete the incomplete constructor method.

The code snippet is given below:

-add method: a method to add an integer to the list.

-toString method: that returns the content of the list with indices.

Program:

//Learnprogramo - programming made simple
//incomplete code:
public class IntegerList{
  private int list[];
  private int elementIndex = 0;
  //Constructor - create an integer list of given 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...
  }
}
//complete code
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;
	}

RainWater Preservation

Sanjana, one day while traveling back home from the office during the rainy season, noticed that rainwater is not preserved and used but rather left for waste. So she wanted to build a system where the rainwater can be trapped, and the system should have the ability to compute how much rain water is trapped.

Let’s assume there is a bunch of bars [grey] showing the below elevation map. The width of each bar is 1. Rainwater is trapped between the grey bars compute. How much water be it can trap after rain?

The elevation map is represented by array[0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1]. In this case, 6 unit of rainwater are being trapped.

Sample Input:

12

0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1

Sample Output:

6

Program:

//Learnprogramo - programming made simple
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;
    }
}

Rangoli Design

//Learnprogramo - programming made simple
import java.util.*;
public class RangoliDesign {
    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");
    }
    }
    }
}

Binary Jump

//Learnprogramo - programming made simple
import java.util.Scanner;
public class Solution {
   public static int binaryJump(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(binaryJump(st));
    }
}

Delete Backups After Kth Run

Gopal is a file backup expert in an audit firm. He’s responsible to create a backup for all transaction files stored in the internal file system. Darshan is a new intern in the file backup team and works along with Gopal in the file backup activity. After doing the file backup activity for a couple of days Darshan realized that unnecessary backups are created which are never used by the system and proposed solutions to Gopal to delete backups after the kth copy is created. Gopal like the proposal and have asked Darshan to write a code demonstrating how the logic will work.

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

Input Format:

The first line contains maximum backup allowed values for any file.

The next line contains a comma-separated positive integer value that represents the file ids.

Output Format:

Print the result in the given format. This is multiple outputs.

The first line should contain the comma-separated file ids whose backups were restored. Ensure that the original order is maintained. The next line should contain the comma-separated file ids in ascending order whose backups 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

Program:

//Learnprogramo - programming made simple
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+",";
			}	
		}
		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);
	}
}

Fix the Palindrome Login

You’re given a function that checks if the string is a palindrome or not. A string is a palindrome if it reads the same from both ends. It will return 1 if the string is a palindrome else return 0. However, this code contains some errors identify the error, and correct them.

Function Description:

Complete the checkPalindrome 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 1 if it’s palindrome else return 0.

Constraint:

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

Sample Input:

madam

Sample Output:

1

Program:

//Learnprogramo - programming made simple
import java.util.Scanner;
public class Palindrome {
	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(checkPalindrome(str));
	}
}

Doug’s Difference

Doug was doing the maths homework with two of his friend at one point they all get bored but Dougs has an idea to pass the time in an interesting way. He decided to play the game of difference such that given sequence of the integers a, a triplet(a[i], a[j], a[k]) is beautiful if:

i < j < k

a[j] – a[i] = a[k] = a[j] = d

Given an increasing sequence of the integers and the value of f, count the number of beautiful triplets in the sequence.

Function Description:

Complete the beautifulTriples function in the editor below. beautifulTriplets have 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:

The 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

Program:

//Learnprogramo - programming made simple
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));
	}
}

String Formatter

Allow the function format(str), str is a string, and return the string’s lengthiest format. A format for this challenge will be defined as if at least 2 or more adjacent alphabets within the string recure at least twice.

For example “aabecaa” contains the format aa whereas “abbbacc” does not contain any format. Your program should return a yes or no pattern.

So, if Str is “aabejiabkfabed” then the output should be yes abe. if Str is “12345” then the output should return no null.

Sample Test Cases:

Input:

da2kr32a2

Output:

yes a2

Input:

sskfssbbb9bbb

Output:

yes bbb

Program:

//Learnprogramo - programming made simple
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));
	}
}

Frequently Asked Questions (FAQ)

Q.1 What is Epam Coding Round?

Ans: The EPAM recruitment process consists of five rounds in which the first round is Online Coding Round. This Round is conducted online and is based on Java.

Q.2 How many Questions are asked in the Coding Round?

Ans: A total of 3 questions are asked in the coding round which candidates have to solve in the time stamp of 2.5 hours.

Q.3 What is the difficulty level of the Epam Coding Questions?

Ans: The questions asked are of medium to high difficulty.

Q.4 What is the Exam pattern of EPAM?

Ans: Epam Recruitment process consists of a total of 5 rounds and the first round is based on coding questions. If you score well in the first round then only you’ll be qualified for the next round.

Q.5 How Can I get Job in Epam?

Ans: To get your dream job in the Epam you’ve to qualify all the 5 rounds which are part of the Epam recruitment process.

Q.6 What does the Epam company do?

Ans: Epam is a multinational American Software company that specializes in service development, digital product design, etc. It is one of the largest manufacturers of custom software.

Q.7 Is it good to Join Epam?

Ans: Of course, it’s very much better to join epam as a fresher because of its package and the opportunities for the freshers.

Conclusion

So, In this way, we’ve solved different epam coding questions with answers asked in the previous years. If you’ve doubt please feel free to contact us. We’ll reach you as soon as possible.

Thanks and Happy coding :)

Also Read: