Infosys recruits for two major profiles with excellent career growth opportunities:
The selection procedure involves three rounds:
The hiring takes place via both On-Campus and Off-Campus drives.
In this recruitment drive, Infosys offers two roles based on the candidate’s performance and eligibility:
| Role | Salary Package |
|---|---|
| System Engineer (SP) | ₹9.5 LPA |
| Digital Specialist Engineer (DSE) | ₹6.25 LPA |
※ The salary figures can change every year depending on the financial performance of the company.
Both the SP and DSE roles include base salary + multiple employee benefits. The total gross salary is higher than the in-hand salary, as certain deductions apply (PF, gratuity, taxes, etc.). The exact structure varies by location, market standards, and company policies.
This is the most eliminatory stage — about 70% of applicants do not clear this round.
The coding assessment consists of three questions:
| Coding Question | Difficulty Level | Eligibility Result |
|---|---|---|
| 1st | Easy | Needed for both roles |
| 2nd | Medium | Needed for both roles |
| 3rd | Hard | Required only for SP role |
This round filters out more than 85% of the remaining candidates.
The interview is taken by mid-level technical managers and includes:
The difficulty level of this interview is high, and clearing this round leads to the HR interview.
This is the final evaluation stage — and although elimination is less compared to the previous rounds, more than 92% of the remaining candidates get filtered here.
The HR panel evaluates:
The interview usually begins with a short personal introduction and moves into psychometric and scenario-based questions.
Infosys Limited is an Indian multinational IT corporation that delivers IT services, consulting, and outsourcing solutions across the globe.
Infosys was started by a group of seven engineers:
What is Object-Oriented Programming?
OOP is a programming paradigm based on real-world objects. It uses concepts like classes, objects, inheritance, and polymorphism. It helps in solving complex problems by modularizing code. OOP increases code reusability and maintainability.
Explain the four pillars of OOP.
The four pillars are Encapsulation, Inheritance, Polymorphism, and Abstraction. They allow modular design and logical grouping of data. Each pillar helps reduce complexity in large applications. These features make OOP scalable and efficient.
What is a Linked List?
A linked list is a linear data structure where each element stores data and a pointer to the next node. It allows dynamic memory allocation unlike arrays. Insertion and deletion are efficient at any position. However, random access is not possible.
Difference between Array and Linked List?
Arrays store elements in contiguous memory while linked lists store scattered nodes. Arrays support random access but linked lists do not. Linked lists allow fast insertion and deletion anywhere. Arrays are better for faster element lookup.
What is a Binary Search Tree (BST)?
A BST is a tree where each left node has smaller values and right node has greater values. Searching, insertion, and deletion are efficient (O(log n) on average). It helps organize sorted data structurally. Performance depends on tree balance.
What is Recursion?
Recursion is a technique where a function calls itself to break problems into smaller versions. It is widely used in tree traversal, backtracking, and dynamic programming. Recursion simplifies logic but consumes more memory. Base case and termination are crucial.
What are Time and Space Complexity?
Time complexity measures how execution time grows with input size. Space complexity measures memory usage during execution. Both help evaluate algorithm efficiency. They ensure optimal solution selection in coding rounds.
What is Dynamic Programming?
Dynamic programming optimizes recursive problems by storing intermediate results. It removes redundant calculations through memoization/tabulation. Used in problems like knapsack, Fibonacci, and LCS. It improves efficiency drastically.
Difference between Stack and Queue?
Stack uses LIFO (Last In First Out) while Queue uses FIFO (First In First Out). Stack operations are push/pop and queue operations are enqueue/dequeue. Stacks are used in recursion and expression evaluation. Queues are used in scheduling and buffering.
What is Multithreading?
Multithreading allows multiple threads to run concurrently within a program. It improves performance when tasks run in parallel. It’s commonly used in OS, web servers, and applications with background services. Proper synchronization is required to avoid conflicts.
What is a Deadlock?
Deadlock occurs when two or more processes wait forever for each other’s resources. It halts system execution completely. Operating systems detect, avoid, or prevent deadlocks using various algorithms. Resource allocation plays a major role.
What is Virtual Memory?
Virtual memory expands RAM by using physical memory + disk space. It enables large programs to run even if RAM is limited. OS swaps pages between RAM and storage. It improves memory management efficiency.
Explain ACID Properties in DBMS.
ACID stands for Atomicity, Consistency, Isolation, and Durability. These properties ensure reliable database transactions. Even system failures cannot corrupt committed transactions. It is essential for financial and critical systems.
What are Joins in SQL?
Joins combine rows from multiple tables using related columns. Types include INNER, LEFT, RIGHT, and FULL JOIN. They help extract meaningful relational data. Joins enable multi-table queries and reporting.
What is Normalization?
Normalization structures database tables to remove redundancy. It improves consistency and prevents data anomalies. Forms include 1NF, 2NF, 3NF, BCNF etc. It ensures efficient data storage and retrieval.
Difference between Primary Key and Unique Key?
Primary key uniquely identifies each row and cannot store NULL. Unique key also ensures uniqueness but can store one NULL. A table can have only one primary key but multiple unique keys. Both maintain data integrity.
What are Triggers in SQL?
Triggers are automatic procedures executed when insert/update/delete events occur. They help maintain data consistency without manual intervention. Used for logging, auditing, and access control. They run internally without user interaction.
Explain REST API.
REST API enables communication between client and server using HTTP methods. It supports GET, POST, PUT, DELETE operations. REST follows stateless architecture to ensure scalability. Widely used in web and mobile applications.
What is Polymorphism?
Polymorphism allows one function to behave differently in different scenarios. It includes compile-time and runtime polymorphism. It increases flexibility in OOP programs. Method overloading and overriding achieve polymorphism.
What is Inheritance?
Inheritance allows a class to acquire attributes and methods from another class. It promotes code reuse and hierarchical structure. Helps avoid duplication and simplifies maintenance. Used heavily in object-oriented design.
Explain Abstraction.
Abstraction hides complex implementation and only shows necessary details. It reduces code complexity and increases security. Achieved using abstract classes and interfaces. Useful in large scalable projects.
What is Encapsulation?
Encapsulation binds data and methods into a single unit (class). It protects internal data from unauthorized access. Access modifiers enforce encapsulation. It improves data safety and modularization.
Explain HashMap.
HashMap stores data in key-value pairs using hashing. It provides average O(1) time complexity for lookup and insertion. Collisions are handled using chaining or open addressing. Useful for implementing dictionaries and caches.
What is a Constructor?
A constructor initializes objects automatically during creation. It has the same name as the class. It allocates memory and sets default values. Overloading constructors enhances flexibility.
Difference between Process and Thread?
A process is an independent program while thread is a lightweight unit inside a process. Threads share memory, processes don’t. Threads improve performance whereas processes improve isolation. Scheduling and memory handling differ for both.
Explain OS Scheduling Algorithms.
Scheduling algorithms decide execution order of processes. Examples: FCFS, SJF, Round Robin and Priority scheduling. They maximize CPU usage and reduce waiting time. Each algorithm suits different system requirements.
Explain TCP vs UDP.
TCP is connection-oriented and reliable, while UDP is connectionless and faster. TCP ensures data delivery with acknowledgments; UDP does not. UDP is preferred for real-time apps like gaming and video streaming. TCP is used for banking and web apps.
What is DNS?
DNS translates domain names into IP addresses. It makes internet browsing user-friendly. DNS servers respond to lookup queries requested by devices. It is essential for global network communication.
Explain Cloud Computing.
Cloud computing provides scalable computing resources over the internet. It eliminates the need for local hardware. Models include IaaS, PaaS, and SaaS. It is widely used for data storage, deployment, and automation.
What are Microservices?
Microservices divide an application into small independent services. Each service focuses on one function and communicates via APIs. It improves scalability, deployment, and fault isolation. Used in modern distributed systems.
What is Garbage Collection?
Garbage collection automatically frees unused memory in languages like Java and Python. It reduces memory leaks and improves performance. Programmer does not manually manage memory. It runs periodically to clear dead objects.
What is Exception Handling?
Exception handling manages runtime errors gracefully without terminating program execution. It ensures smooth user experience. Try-catch blocks are used to handle exceptions. It helps in debugging and system reliability.
Explain Static vs Dynamic Typing.
Static typing checks types at compile time, dynamic typing checks at runtime. Static typing improves performance; dynamic typing improves flexibility. Java and C++ are statically typed, Python is dynamically typed. Both approaches suit different use cases.
What is Pass by Value vs Pass by Reference?
Pass by value sends a copy of data to functions; changes don’t affect original. Pass by reference sends memory address; modifications reflect in original data. It affects performance and memory usage. Choice depends on language design.
What is Multilevel Inheritance?
It is a type of inheritance where a child class inherits from a derived class. It forms a multi-level parent-child hierarchy. It promotes reusability and specialization. Careful design avoids ambiguity.
Explain Interface.
Interface provides a contract of abstract methods without implementations. Classes that implement the interface must define the methods. It supports multiple inheritance in OOP. Used for modular and scalable design.
What is an Abstract Class?
An abstract class contains one or more abstract methods. It cannot be instantiated directly. It provides partial implementation to subclasses. Useful when functions must be overridden.
Explain Merge Sort.
Merge sort is a divide-and-conquer algorithm that splits and merges sorted sublists. It provides O(n log n) time consistently. Uses extra memory for merging. Suitable for sorting linked lists.
What is Quick Sort?
Quick sort selects a pivot and partitions array around it. Average time is O(n log n), worst case O(n²). It does not require extra memory like merge sort. One of the fastest in-place sorting methods.
Explain Heap Data Structure.
Heap is a tree-based structure where each parent is greater (max heap) or smaller (min heap) than children. It is used to implement priority queues. Supports fast extraction of extreme values. Insertions and deletions are efficient.
What is a Graph?
Graph is a nonlinear structure of nodes (vertices) connected by edges. It models networks like roads, social media, and internet routing. Graph search uses BFS and DFS. Weighted graphs support shortest path algorithms like Dijkstra.
What is REST vs SOAP?
REST is lightweight and uses HTTP protocols. SOAP is a heavyweight protocol with strict security standards. REST is preferred for modern APIs; SOAP suits banking and government systems. Both support client-server communication.
Explain JWT (JSON Web Token).
JWT is used for secure authentication between client and server. It stores user details digitally and validates each request. It prevents unauthorized access without storing session data on server. Widely used in login-based systems.
What is CI/CD?
CI/CD automates integration and deployment of software updates. It reduces manual efforts and deployment errors. Tools include Jenkins, GitHub Actions, and GitLab CI. It supports DevOps culture.
What is Docker?
Docker helps in packaging applications with dependencies in isolated containers. It ensures consistent execution across environments. It supports faster deployment and microservices. Helps eliminate “runs on my machine” issues.
What is Kubernetes?
Kubernetes manages containerized applications on clusters. It provides automatic scaling and load balancing. It restarts failed containers automatically. Widely used for distributed deployments.
What is a Software Development Life Cycle (SDLC)?
SDLC defines phases from requirement gathering to deployment. Phases include planning, design, development, testing, and maintenance. It ensures quality and timely delivery. Models include Waterfall, Agile, and DevOps.
Explain Agile Methodology.
Agile divides software development into iterative sprints. It promotes flexibility and continuous customer feedback. It delivers incremental improvements. Scrum is the most popular Agile framework.
Explain VCS (Version Control System).
VCS tracks code changes and allows collaboration among developers. Git is the most widely used VCS. It supports branching, merging, and rollback. Essential for teamwork in tech companies.
Describe your major project.
Companies evaluate technical ability using project discussions. You should explain architecture, technologies used, and challenges solved. Focus more on your contributions rather than team work. Interviewers often ask follow-ups from this topic.
Consider a sorted array A[] containing n elements. The task is to determine the presence of a given element x in array A. Unlike traditional binary search, this approach involves the random selection of an element within the specified range for the search process. Discuss the methodology for performing this randomized search and analyze its efficiency
Given an array, the task is to reverse the array without using the subtract sign ‘-‘ anywhere in your code. It is not tough to reverse an array but the main thing is to not use the ‘-‘ operator.
Given an array (or string), the task is to reverse the array/string.
Examples :
Input : arr[] = {1, 2, 3}
Output : arr[] = {3, 2, 1}
Input : arr[] = {4, 5, 1, 2}
Output : arr[] = {2, 1, 5, 4}
Given an array A[] of n numbers and another number x, the task is to check whether or not there exist two elements in A[] whose sum is exactly x.
Example:
Input: arr[] = {0, -1, 2, -3, 1}, x= -2
Output: Yes
Explanation: If we calculate the sum of the output,1 + (-3) = -2
Input: arr[] = {1, -2, 1, 0, 5}, x = 0
Output: No
Given a Linked List, the task is to insert a new node in this given Linked List at the following positions:
At the front of the linked list
After a given node.
At the end of the linked list.
Given a weighted graph and a source vertex in the graph, find the shortest paths from the source to all the other vertices in the given graph.
Note: The given graph does not contain any negative edge.
Example:
Input: src = 0, the graph is shown below.
Output: 0 4 12 19 21 11 9 8 14
Explanation: The distance from 0 to 1 = 4.
The minimum distance from 0 to 2 = 12. 0->1->2
The minimum distance from 0 to 3 = 19. 0->1->2->3
The minimum distance from 0 to 4 = 21. 0->7->6->5->4
The minimum distance from 0 to 5 = 11. 0->7->6->5
The minimum distance from 0 to 6 = 9. 0->7->6
The minimum distance from 0 to 7 = 8. 0->7
The minimum distance from 0 to 8 = 14. 0->1->2->8
Given a 2D grid of 0s and 1s, where 1 represents land and 0 represents water, determine the number of islands. An island is formed by a group of connected land cells, where “connected” means horizontally or vertically adjacent. Find and return the total number of islands in the grid.
Example:
Input: mat[][] = {{1, 1, 0, 0, 0},
{0, 1, 0, 0, 1},
{1, 0, 0, 1, 1},
{0, 0, 0, 0, 0},
{1, 0, 1, 0, 0}}
Output: 4
Given an N x N matrix containing a mix of zero, positive, and negative numbers, find the maximum sum of a submatrix with dimensions k x k, where k is a positive integer less than or equal to N. In other words, identify a square submatrix of size k such that the sum of its elements is maximized.
Example:
Input:
[
[1, 2, -1, 4],
[-8, 3, 4, 2],
[3, -1, 6, 1],
[2, 0, 2, -8]
]
k = 2
Output: 14
Given an array arr of size N, the goal is to determine the maximum possible sum of products, where each element arr[i] is multiplied by its corresponding index i, and the array can be rotated any number of times.
Example:
Input: arr[] = {1, 20, 2, 10}
Output: 72.We can get 72 by rotating the array twice.
{2, 10, 1, 20}
20*3 + 1*2 + 10*1 + 2*0 = 72
Input: arr[] = {10, 1, 2, 3, 4, 5, 6, 7, 8, 9}
Output: 330
We can get 330 by rotating the array 9 times.
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
0*1 + 1*2 + 2*3 … 9*10 = 330
Given three arrays of the same size, the task is to find a triplet such that the difference between the maximum and minimum elements in the triplet is minimized compared to all other possible triplets. Each triplet should be composed of one element from each of the three given arrays.
In case there are multiple triplets with the same minimum difference, the solution should prioritize the triplet with the smallest sum of its elements.
Example:
Input : arr1[] = {5, 2, 8}
arr2[] = {10, 7, 12}
arr3[] = {9, 14, 6}
Output : 7, 6, 5
Input : arr1[] = {15, 12, 18, 9}
arr2[] = {10, 17, 13, 8}
arr3[] = {14, 16, 11, 5}
Output : 11, 10, 9
Given two positive numbers a and b, the objective is to find and print the least common multiple of the a-th and b-th Fibonacci numbers. The Fibonacci sequence is defined as follows:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..
where 0 is considered as the 0-th Fibonacci number.”
Example:
Input : a = 3, b = 12
Output : 144
Input : a = 8, b = 37
Output : 507314157
Given a positive integer n, the task is to determine the count of ordered pairs (a,b) such that gcd(a,b) = b
Given an array of “n” positive integers containing repeated elements, the goal is to identify the maximum difference in frequency between any two distinct elements. The condition is that the element with the higher frequency must also have a greater numerical value than the second element
Example:
Input : arr[] = { 3, 1, 3, 2, 3, 2 }.
Output : 2
Frequency of 3 = 3.
Frequency of 2 = 2.
Frequency of 1 = 1.
Here the difference of frequency of element 3 and 1 is = 3 – 1 = 2.
Also 3 > 1.
Given a binary tree where each node has an associated value, the objective is to select a subset of nodes to maximize the sum of their values. The constraint is that no two chosen nodes in the subset can be directly connected, meaning that if a node is included, its children cannot be included, and vice versa.
Given the array representation of Complete Binary Tree i.e, if index i is the parent, index 2*i + 1 is the left child and index 2*i + 2 is the right child. The task is to find the minimum number of swap required to convert it into a Binary Search Tree.
Example:
Input : arr[] = { 5, 6, 7, 8, 9, 10, 11 }
Output : 3
Binary tree of the given array:
Swap 1: Swap node 8 with node 5.
Swap 2: Swap node 9 with node 10.
Swap 3: Swap node 10 with node 7.
Given an array of integers, our task is to write a program that efficiently finds the second-largest element present in the array.
Example:
Input: arr[] = {12, 35, 1, 10, 34, 1}
Output: The second largest element is 34.
Explanation: The largest element of the array is 35 and the second largest element is 34
Input: arr[] = {10, 5, 10}
Output: The second largest element is 5.
Explanation: The largest element of the array is 10 and the second largest element is 5
Input: arr[] = {10, 10, 10}
Output: The second largest does not exist.
Explanation: Largest element of the array is 10 there is no second largest element
In the context of daily share trading, a trader engages in buying shares in the morning and selling them on the same day. The trader is permitted to execute at most two transactions, and the second transaction can only commence once the first one is concluded (Buy->Sell->Buy->Sell). The task is to determine the maximum profit achievable by the trader based on the stock prices observed throughout the day.
Example:
Input: price[] = {10, 22, 5, 75, 65, 80}
Output: 87
Trader earns 87 as sum of 12, 75
Buy at 10, sell at 22,
Buy at 5 and sell at 80
Input: price[] = {2, 30, 15, 10, 8, 25, 80}
Output: 100
Trader earns 100 as sum of 28 and 72
Buy at price 2, sell at 30, buy at 8 and sell at 80
Input: price[] = {100, 30, 15, 10, 8, 25, 80};
Output: 72
Buy at price 8 and sell at 80.
Input: price[] = {90, 80, 70, 60, 50}\
Output: 0
Not possible to earn.
Create a function that, given an array and a number ‘x’, removes all occurrences of ‘x’ from the array. The array is characterized by two attributes: capacity and size. It’s important to note that when removing an item, the capacity remains unchanged, and only the size of the array is adjusted.
Example:
Input: arr[] = {3, 1, 2, 5, 90}, x = 2, size = 5, capacity = 5
Output: arr[] = {3, 1, 5, 90, _}, size = 4, capacity = 5
Input: arr[] = {3, 1, 2, _, _}, x = 2, size = 3, capacity = 5
Output: arr[] = {3, 1, _, _, _}, size = 2, capacity = 5
Given an array of integers, we need to find out whether it is possible to construct at least one non-degenerate triangle using array values as its sides. In other words, we need to find out 3 such array indices which can become sides of a non-degenerate triangle.
Example:
Input : [4, 1, 2]
Output : No
No triangle is possible from given
array values
Input : [5, 4, 3, 1, 2]
Output : Yes
Sides of possible triangle are 2 3 4
Given an array arr[] of size N, the task is to find the maximum value of arr[i] ∗ arr[j] + arr[i] − arr[j] for any pair (arr[i], arr[j]) from the given array, where i != j and 0 < i, j < N – 1.
Example:
Input: arr[] = {1, 2, 3, 4, 5}
Output: 21
Explanation:
Among all the pairs of the array, the maximum value is obtained for the pair (arr[4], arr[3]), which is equal to
=> arr[4] * arr[3] + arr[4] – arr[3] = 5 * 4 + 5 – 4 = 20 + 1 = 21.
Input: {-4, -5, 0, 1, 3}
Output: 21
Explanation:
Among all the pairs of the array, the maximum value is obtained for the pair (arr[0], arr[1]), which is equal to
=> arr[0] * arr[1] + arr[0] – arr[1] = (-4) * (-5) + (-4) – (-5) = 20 + 1 = 21.
A Clique is a subgraph of a graph such that all vertices in the subgraph are completely connected with each other. Given a Graph, find if it can be divided into two Cliques.
Example:
Input : G[][] = {{0, 1, 1, 0, 0},
{1, 0, 1, 1, 0},
{1, 1, 0, 0, 0},
{0, 1, 0, 0, 1},
{0, 0, 0, 1, 0}};
Output : Yes
Given a matrix. Convert it into a linked list matrix such that each node is connected to its next right and down node.
Example:
Input : 2D matrix
1 2 3
4 5 6
7 8 9
Output :
1 -> 2 -> 3 -> NULL
| | |
v v v
4 -> 5 -> 6 -> NULL
| | |
v v v
7 -> 8 -> 9 -> NULL
| | |
v v v
NULL NULL NULL
Consider an array of elements. For each element in the array, determine and print the Next Greater Element (NGE). The Next Greater Element for an element is defined as the first element to the right that is greater than the current element. Provide the solution algorithm and output the NGE for every element in the given array
Example:
Input: arr[] = [ 4 , 5 , 2 , 25 ]
Output: 4 –> 5
5 –> 25
2 –> 25
25 –> -1
Explanation: except 25 every element has an element greater than them present on the right side
Input: arr[] = [ 13 , 7, 6 , 12 ]
Output: 13 –> -1
7 –> 12
6 –> 12
12 –> -1
Explanation: 13 and 12 don’t have any element greater than them present on the right side.
Write a function that takes a list sorted in non-decreasing order and deletes any duplicate nodes from the list. The list should only be traversed once.
For example if the linked list is 11->11->11->21->43->43->60 then removeDuplicates() should convert the list to 11->21->43->60.
Given a doubly linked list, devise a function to perform an ascending order sort on the elements using the merge sort algorithm. Implement the necessary steps to ensure the resulting doubly linked list is in increasing order. As an example, demonstrate the transformation of a given doubly linked list into the sorted form, e.g., {2, 4, 8, 10}. Provide the algorithm and steps involved in the sorting process
You have been given a string S of length N. The given string is a binary string which consists of only 0’s and ‘1’s. Ugliness of a string is defined as the decimal number that this binary string represents.
Example:
“101” represents 5.
“0000” represents 0.
“01010” represents 10.
Khaled has an array A of N elements. It is guaranteed that N is even. He wants to choose at most N/2 elements from array A. It is not necessary to choose consecutive elements. Khaled is interested in XOR of all the elements he chooses. Here, XOR denotes the bitwise XOR operation.
Example:
If A=[2,4,6,8], then khaled can choose the subset [2,4,8] to achieve XOR=(2 XOR 4 XOR 8)=14.
Khaled wants to maximize the XOR of all the elements he chooses. Your task is to help khaled to find the max XOR of a subset that he can achieve by choosing at most N/2 elements?
Given a tree consisting of n vertices, each vertex is either colored black or white. The task is to compute for each vertex v, the maximum difference between the number of white and the number of black vertices if a subtree of the given tree is chosen that contains the vertex v.
Example:
Input: n = 9, color = { 0, 1, 1, 1, 0, 0, 0, 0, 1 }, edges = { { 1, 2 }, { 1, 3 }, { 3, 4 }, { 3, 5 }, { 2, 6 }, { 4, 7 }, { 6, 8 }, { 5, 9 } }
Output: 2 2 2 2 2 1 1 0 2
Input: n = 4, color = { 0, 0, 1, 0}, edges = {{1, 2}, {1, 3}, {1, 4}}
Output: 0 -1 1 -1
Create a function that takes an array A[] composed of only 0s, 1s, and 2s. The goal is to sort the array such that all 0s appear first, followed by all 1s, and finally, all 2s. Implement the function to achieve this specific ordering of elements in the array.
Example:
Input: {0, 1, 2, 0, 1, 2}
Output: {0, 0, 1, 1, 2, 2}
Input: {0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1}
Output: {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2}
Consider a string array S and the objective is to determine the lexicographically smallest string that can be constructed by selecting a single character from each string in the array S. Formulate the steps or algorithm to find this lexicographically smallest string based on the given criteria
Example:
Input: S = [“xy”, “fd”]
Output: “dx”
Explanation: The possible strings formed by extracting a single character from each string are [“xf”, “fx”, “xd”, “dx”, “yf”, “fy”, “yd”, “dy”]. The lexicographically smallest string obtained is “dx”.