United Lex Coding Questions and Answers

United Lex Coding Questions with Solutions

Here, in United Lex Coding Questions and Answers page we have given Sample United Lex Coding Questions with Solutions that will help you for preparing for United Lex Recruitment Drive. 

Go through this page to get all Sample United Lex Coding Questions and at last get FAQ’s related to United Lex Recruitment Drive.

United-Lex-Coding-Questions

United Lex Coding Questions and Answers - Set 1

Question 1: Password ASCII

Problem statement : Aman, who is working at a software company forgot the password of his Linkedin id.But he knows the ASCII values of his password in reverse order. Help aman to find the password.
To decode the password, first reverse the string of digits, then successively pick valid values from the string and convert them to their ASCII equivalents. Some of the values will have two digits, and others three. Use the ranges of valid values when decoding the string of digits.

Some of the ASCII values are given with their characters:

  •  The ASCII value of A to Z is 65 to 90.
  •  The ASCII value of a to z is 97 to 122.
  •  The ASCII value of space characters is 32.

Note: The password only has alphabets and blank spaces.

Given a string , decode the password by following the steps mentioned above.

Constraints:

  • 1<= |s| <=10^5
  • s[i] is an ascii character in the range [A-Za-z] or a space character

Sample Input:

  • 796115110113721110141108

Sample Output:

  • PrepInsta

Explanation 

  • The reversed string will be 801141011127311011511697, which if analysed as ascii will be “PrepInsta”

Solution:

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Question 2 : Game Of Clicks (R->Hard)

Problem Statement  :

Sahil watches TV all day and gets bored. He started playing this dumb game of identifying minimum number of inputs needed to reach a channel. As his cousin, you have to help him, but you live far from his house. So you decide to write a code that will ask Sahil for some inputs and give outputs respectively.

Here are the problems you need to keep in mind :

  • There are 13 buttons on his remote: 10 buttons for the numbers (0-9) to form integers denoting respective channel index, “Up channel” button and “ Down channel” button for going i +1th channel and i-1th channel from i respectively, and a “Last viewed” button to see what’s the last channel before it.
  • The number buttons allow you to jump directly to a specific channel (Ex: to go to channel 172 by typing 1,7,2).
  • If the channel which you are in is ith and that is the max channel index possible, by Up channel, you will reach the first channel possible. Same goes for the down channel button. You can go to the highest channel possible if you go down from the lowest channel possible.
  • Sahil can get from one channel to the next in one of the two ways.
  • Sahil’s parents have set some parental control on some channels on Aniruth’s television. The “Up Channel “ and “Down buttons” buttons skip these channels as these channels are not viewable.
  • Given a list of channels to view, the lowest channel, the highest channel, and a list of blocked channels, your program should return the minimum number of clicks necessary to get through all the shows that Anirudh would like to match.

Input Format :

  • First line is the lowest Channel
  • Second-line is the highest Channel
  • Followed by a number of blocked channels B,
    and the next B lines contain the actual blocked channels.
  • Followed by the number of Channels to view V, and the next V lines contain the actual channels to view.

Constraints :

  • The lowest channel on the television will be greater than 0. and less than or equal to 10,000.
  • The highest channel on the television will be greater than or equal to the lowest channel. and less than or equal to 10.000.
  • The list of channels that are blocked on Anirudh’s television. All the channels in this list will be valid channels (greater than or equal to lowest channel, less than or equal 1 to highest channel). Duplicates may be Ignored. The blocked list can be a maximum of 40 channels.
  • The sequence that Sahil must view contains between 1 and 50 elements. inclusive. All channels in this sequence are not in the blocked list and are between lowest channel and highest channel. Inclusive.

Sample Input 0:
1
20
2
18
19
5
15
14
17
1T
17
Sample output 0:
7

Question 3: Formatting large Products

Problem Statement: Rohan is weak in mathematics.He is giving mathematics  Olympiad , but he got stuck in one of the question .Help rohan to solve the question.In Question there are two positive integer A and B. You have to find the product of all integer between A and B which is represented in the form C=D*10^E , where  C is the product of numbers , D and E are non-negative integers and the last digit of D is non-zero.

Function Description 

  • Complete the function formatProducts in the editor below, formatProduct must return a string that represents C in the above described form.
  • Function has the following parameters
  • A: an integer
  • B: an integer

Constraints

  •    A will between 1 and 1,000,000 . Inclusive.
  •    B will be between A and 1,000,000. Inclusive.

Sample Input 0 

  • 1
  • 5

Sample Output 0

  • 12 * 10^1

Explanation 

  • 1*2*3*4*5=120 = 12 * 10^1

Sample Input 1

  • 3
  • 10

Sample Output 1

  • 18144 * 10^2

Explanation

  • 3*4*….*10=1814400 =18144 * 10^2

Question 4: Queries for Count

The task is to determine the number of elements within a specified range in an unsorted array. Given an array of size n, the goal is to count the elements that fall between two given values, i and j, inclusively.
Examples:

Input:
Array: [1, 3, 3, 9, 10, 4]
Range 1: i = 1, j = 4
Range 2: i = 9, j = 12

Output:
For Range 1: 4
For Range 2: 2

Explanation:
In the first query, the numbers within the range 1 to 4 are 1, 3, 3, and 4.
In the second query, the numbers within the range 9 to 12 are 9 and 10.

Question 5: Password Hacker

Problem statement :

Elliot made a KeyLogger for his friend Romero, so that he can see the passwords of his friend. Keylogger is a software that can tell you the buttons pressed in the keyboard without the consent of the user, and hence unethical. Elliot made it to hack Romero’s passwords. The one problem is, Romero writes the passwords in lowercase characters only, and the keylogger only takes the values of the keys. Like, for a it takes 1, for b 2, and for z 26. For a given number Elliot produces all combinations of passwords in a dictionary and starts a dictionary based password attack. For a given number, print all the possible passwords in a lexicographic order.

Input Format:

One line, denoting the value given by the keylogger

Output Format:

All possible combinations of keyloggers in new lines are lexicographically ordered.

Constraints:

2<=Number of digit in input<=1000

Sample Input:

1234

Sample Output:

abcd

axd

Mcd

Explanation:

For 12, you can take 1,2 that is ab, or you can take l.

United Lex Coding Questions and Answers - Set 2

Question 6 :A Good Prime Number

Problem Statement  :

A prime number is a number which is divisible by one and itself. Also a number is called a good  prime number if the sum of its digits is a prime number. For example a number 23 is a good prime number because the sum of 2 and 3 ( 2+3=5) is 5 which is a prime number. You are given an integer K. Your task is to find the kth good prime number that is greater than a provided number N.

For example , 232 is a good prime number since the sum of all digits is 7 which is a prime number whereas 235 is not a good prime number.

Input format :

  • The first line contains an integer N.
  • The next line contains an integer K.

Output format :

A single integer which is a Kth good prime number that is greater than a provided number N.

Constraints :

  • 1<=N<=10^5
  • 1<=K<<=10^5

Sample Input 1:

4  4

Sample Output 1:

12

Explanation :

Good prime numbers starting from 4 are 5,7,11(1+1=2 which is prime number),12(1+2=3 which is prime number),14(1+4=5 which is a prime number) and so on. Because the sum of digits of an individual number is a prime number And 4 th good prime number is 12 in this series.Hence the output is 12. 

Sample Input 2:

17  5

Sample Output 2:

29

Explanation :

Good prime numbers starting from 17 are 20,21,23,25,29…and the 5th prime number is 29.Hence the output is 29.

Question 7 : Loki’s Mind Stone

 

 

Problem Statement  :

Loki, the God of mischief can brainwash any living person by touching him/her with his Mind stone, and has decided to break the avengers (a warrior group) to face into each other, so that they can turn against each other and make Loki’s evil plans easier. Now all the avengers have some amount of strength that is denoted in integers. Loki wants to brainwash the least amount of people possible, because he is lazy. But he wants his team of avengers to win the battle. What is the number of avengers Loki will get brainwashed.

Input Format:
First line contains an integer n, denoting the number of total avengers
the next line contains n space separated integers denoting the power of each avenger.

Output Format:
One line denoting the total number of avengers brainwashed by Loki’s Mind stone.

Constraints:
2<=n<=10^6

Test case:
Sample Input:
6
9 3 1 2 4 2

Sample Output:
2

Output Specifications:
Loki can brainwash the avengers with power 9 and 3, or with 9 and 2, or with 9,4, and the rest will be losing cause cumulative power of rest avengers is less than the brainwashed total power by Loki.

Question 8 : Spiral Matrix

Problem Statement :

You will be given a 2d matrix. Write the code to traverse the matrix in a spiral format. Check the input and output for better understanding.

Sample Input :
Input :
5 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20

Output :

1 2 3  4 5 6 7 8 9 10 11 12 13 14  15 16 17 18 19 20

Question 9 : Coin Game

Raman was playing a game,  he starts with x coins. Now in every step, he wins and loses and he has to get the money or pay the money as needed. He came in contact with a psychic who can see the future and the Psychic predicted the outcomes after each step. Now Raman wants to start the game with the minimum wage where he doesn’t run out of money.  Help Raman to find what money he should start with. The only rule to keep playing is not going in a credit situation.

Input Format:

  • First line with n, number of steps in the game
  • Next n lines, n integers denoting outcomes of every game. Positive means winning and negative means losing that money.

Output Format:

  • One single integer denoting the minimum amount to start with

Constraints:

  • Number of steps<=10^9
  • -1000<=Money needed in each step<=1000

Sample Input:

    4
    2
    -9
    15
     2

Sample Output:

    7

Explanation:

If he starts with 7 rupees, then after steps : 7 ->9 -> 0-> 15 -> 17.

Question 10 : Profit balance

Problem Statement  :

Anand and Brijesh got a bunch of profit in their business. Now it’s time to divide the profit between themselves. Anand being the one with the calculator was the one who could decide who will get how much. But as he was one hell of an honest guy, he can’t cheat on Brijesh to get some extra money. So he decided to divide them in such a way where they can get almost the same amount possible. Although, it is sometimes impossible to divide the profit into two, because the profits must be written in their production managed copy in a way where you cannot share the profit of a single thing, A single Profit will be held by a single person.
you are the one who is called to mitigate the problem. Given an array of profit, find out in the process, what can be the minimum difference between them in terms of income.

Constraints:

  • 1<=N<=10^3
  • 0<=Profits<=100

Input Format:

  • First line contains an integer N, number of profits.
  • Next line, N space separated Integers denoting the i-th Profit.

Output:

  • A single integer denoting minimum possible difference between the total profits.

Sample Input:
4
1 2 3 4

Output:
0
Explanation:
He will take 1 and 4, so his profit will be 5, so the difference will be 0.

FAQs related to United Lex Coding Questions and Answers

Question 1: What does United Lex do?

UnitedLex is a company specializing in data and professional services. They focus on delivering results that add value to top-performing law firms and corporate legal departments. Their expertise lies in various domains, including litigation and investigations, intellectual property, contracts, compliance, and legal operations.

Question 2: Does United Lex includes Coding Questions in Hiring Process?

Yes, United Lex includes Coding Questions in their Technical Interview and Online Assessments along with Aptitude Questions in their Recruitment Drive for hiring freshers.

Question 3: What is the Eligibility Criteria for United Lex Recruitment Process for Freshers ?
  • B.Tech in Any Stream
  • Eligible Batch : 2024
  • Minimum 7 CGPA or Equivalent Percentage is required for applying
  • No active backlogs
Question 4: What are the Job Roles offered by United Lex ?

Here are the following Job Roles Offered by United Lex:

  • SDE Intern
  • Associate Software Engineer
Question 5: What is the selection process of United Lex ?

The United Lex Recruitment Process includes:

  • Online Assessment
  • Technical Interviews
  • HR Interviews
Question 6: What is the Salary offered by United Lex?
  • For Associate Level Post: ₹ 7 LPA

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription