Accenture
50+ Marksans Pharma Interview Questions and Answers
Q1. Triplets with Given Sum Problem
Given an array or list ARR
consisting of N
integers, your task is to identify all distinct triplets within the array that sum up to a specified number K
.
Explanation:
A triplet i...read more
The task is to find all distinct triplets in an array that sum up to a specified number.
Iterate through the array and use nested loops to find all possible triplets.
Keep track of the triplets that sum up to the target number.
Handle cases where no triplet exists for a given target sum.
Q2. Kth Smallest and Largest Element Problem Statement
You are provided with an array 'Arr' containing 'N' distinct integers and a positive integer 'K'. Your task is to find the Kth smallest and Kth largest element...read more
Find the Kth smallest and largest elements in an array.
Sort the array and return the Kth element for smallest and (N-K+1)th element for largest.
Ensure K is within the array size to avoid out of bounds error.
Handle multiple test cases efficiently by iterating through each case.
Q3. Chocolate Distribution Problem
You are given an array/list CHOCOLATES
of size 'N', where each element represents the number of chocolates in a packet. Your task is to distribute these chocolates among 'M' stude...read more
Distribute chocolates among students to minimize the difference between the largest and smallest number of chocolates.
Sort the array of chocolates packets.
Use sliding window technique to find the minimum difference between the largest and smallest packets distributed to students.
Return the minimum difference as the output.
Q4. Balanced Parentheses Combinations
Given an integer N
representing the number of pairs of parentheses, find all the possible combinations of balanced parentheses using the given number of pairs.
Explanation:
Con...read more
Generate all possible combinations of balanced parentheses given the number of pairs.
Use backtracking to generate all valid combinations of balanced parentheses.
Keep track of the number of open and close parentheses used in each combination.
Recursively build the combinations by adding open parentheses if there are remaining, and then adding close parentheses if the number of open parentheses is greater than the number of close parentheses.
Example: For N = 2, valid combination...read more
Q5. Armstrong Number Problem Statement
You are provided an integer 'NUM'. Determine if 'NUM' is an Armstrong number.
Explanation:
An integer 'NUM' with 'k' digits is an Armstrong number if the sum of its digits, ea...read more
An Armstrong number is a number that is equal to the sum of its own digits raised to the power of the number of digits.
Iterate through each digit of the number and calculate the sum of each digit raised to the power of the total number of digits.
Compare the calculated sum with the original number to determine if it is an Armstrong number.
Return 'YES' if the number is an Armstrong number, 'NO' otherwise.
Q6. One of the questions for Critical Reasoning was:- Two cars A and B cross a flyover in 10 minutes and 30 minutes respectively. Find the speed of Car A. Statements: Car B travels at the 50kmph Train A and B are t...
read moreCar A's speed is 90kmph
Use the formula: Speed = Distance/Time
Assume the distance to be the same for both cars
Calculate Car A's time using the given information
Substitute the values in the formula to get Car A's speed
Q7. Equilibrium Index Problem Statement
Given an array Arr
consisting of N integers, your task is to find the equilibrium index of the array.
An index is considered as an equilibrium index if the sum of elements of...read more
Find the equilibrium index of an array where sum of elements on left equals sum on right.
Iterate through the array and calculate the total sum of all elements.
For each index, calculate the left sum and right sum and check if they are equal.
Return the index if found, otherwise return -1.
Q8. Pair Sum Problem Statement
You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.
Note:
Each pa...read more
Find pairs of elements in an array that sum up to a given value, sorted in a specific order.
Iterate through the array and use a hashmap to store the difference between the target sum and each element.
Check if the difference exists in the hashmap, if yes, add the pair to the result list.
Sort the result list based on the criteria mentioned in the problem statement.
Return the sorted list of pairs as the final output.
Q9. Tiling Problem Statement
Given a board with 2 rows and N columns, and an infinite supply of 2x1 tiles, determine the number of distinct ways to completely cover the board using these tiles.
You can place each t...read more
The problem involves finding the number of distinct ways to completely cover a 2xN board using 2x1 tiles.
Use dynamic programming to solve the tiling problem efficiently.
Define a recursive function to calculate the number of ways to tile the board.
Consider both horizontal and vertical placements of tiles.
Implement the function to handle large values of N by using modulo arithmetic.
Optimize the solution to avoid redundant calculations.
Q10. Find Middle of Linked List
Given the head node of a singly linked list, your task is to return a pointer pointing to the middle node of the linked list.
When the number of elements is odd, return the middle ele...read more
Return the middle node of a singly linked list, selecting the one farther from the head node in case of even number of elements.
Traverse the linked list using two pointers, one moving twice as fast as the other.
When the fast pointer reaches the end, the slow pointer will be at the middle node.
Return the node pointed by the slow pointer as the middle node.
Q11. Question 2 was, Find the sum of all numbers in range from 1 to m(both inclusive) that are not divisible by n. Return difference between sum of integers not divisible by n with sum of numbers divisible by n.
Find sum of numbers in range 1 to m (both inclusive) not divisible by n. Return difference between sum of non-divisible and divisible numbers.
Iterate through range 1 to m and check if number is divisible by n.
If not divisible, add to sum of non-divisible numbers.
If divisible, add to sum of divisible numbers.
Return difference between sum of non-divisible and divisible numbers.
Q12. Palindrome String Validation
Determine if a given string 'S' is a palindrome, considering only alphanumeric characters and ignoring spaces and symbols.
Note:
The string 'S' should be evaluated in a case-insensi...read more
Check if a given string is a palindrome after removing special characters, spaces, and converting to lowercase.
Remove special characters and spaces from the string
Convert the string to lowercase
Check if the modified string is a palindrome by comparing characters from start and end
Q13. Replace Spaces in a String
Given a string STR
consisting of words separated by spaces, your task is to replace all spaces between words with the characters "@40".
Input:
The first line contains an integer ‘T’ d...read more
Replace spaces in a string with '@40'.
Iterate through the string and replace spaces with '@40'.
Return the modified string for each test case.
Handle multiple test cases by iterating through each one.
Q14. Check if Two Trees are Mirror
Given two arbitrary binary trees, your task is to determine whether these two trees are mirrors of each other.
Explanation:
Two trees are considered mirror of each other if:
- The r...read more
Check if two binary trees are mirrors of each other based on specific criteria.
Compare the roots of both trees.
Check if the left subtree of the first tree is the mirror of the right subtree of the second tree.
Verify if the right subtree of the first tree is the mirror of the left subtree of the second tree.
Q15. Postfix Expression Evaluation Problem Statement
Given a postfix expression, your task is to evaluate the expression. The operator will appear in the expression after the operands. The output for each expression...read more
Q16. Ways To Make Coin Change
Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more
The task is to determine the total number of ways to make change for a specified value using given denominations.
Create a dynamic programming table to store the number of ways to make change for each value up to the target value.
Iterate through each denomination and update the table accordingly.
The final answer will be the value in the table at the target value.
Consider edge cases such as when the target value is 0 or when there are no denominations available.
Q17. Reverse the String Problem Statement
You are given a string STR
which contains alphabets, numbers, and special characters. Your task is to reverse the string.
Example:
Input:
STR = "abcde"
Output:
"edcba"
Input...read more
Q18. Ninja and Alien Language Order Problem
An alien dropped its dictionary while visiting Earth. The Ninja wants to determine the order of characters used in the alien language, based on the given list of words fro...read more
Determine the order of characters in an alien language based on a list of words from the alien's dictionary.
Create a graph data structure to represent the relationships between characters in the words.
Perform a topological sort on the graph to find the order of characters.
Handle cases where there is no valid order by returning an empty string.
Q19. Stack using Two Queues Problem Statement
Develop a Stack Data Structure to store integer values using two Queues internally.
Your stack implementation should provide these public functions:
Explanation:
1. Cons...read more
Implement a stack using two queues to store integer values with specified functions.
Use two queues to simulate stack operations efficiently.
Maintain the top element in one of the queues for easy access.
Handle push, pop, top, size, and isEmpty functions as specified.
Ensure proper error handling for empty stack scenarios.
Optimize the implementation to achieve desired time complexity.
Example: Push 42, pop top element (42), push 17, top element is 17.
Q20. Find the Second Largest Element
Given an array or list of integers 'ARR', identify the second largest element in 'ARR'.
If a second largest element does not exist, return -1.
Example:
Input:
ARR = [2, 4, 5, 6, ...read more
Find the second largest element in an array of integers.
Iterate through the array to find the largest and second largest elements.
Handle cases where all elements are identical.
Return -1 if a second largest element does not exist.
Q21. Write a code for the length of string without using strlen() function.
Code to find length of string without using strlen() function.
Use a loop to iterate through each character of the string
Increment a counter variable for each character in the string
Stop the loop when the null character '\0' is encountered
Return the counter variable as the length of the string
I managed network calls using RESTful APIs and structured the backend with a MVC architecture.
Utilized RESTful APIs to make network calls between the frontend and backend
Implemented a Model-View-Controller (MVC) architecture to organize backend code
Used frameworks like Spring Boot or Express.js to handle network requests and responses
Q23. Longest Factorial where I have to print the longest factorial .
The longest factorial that can be printed depends on the data type used to store the result.
Factorials grow very quickly, so the data type used to store the result is important.
For example, the largest factorial that can be stored in a 32-bit integer is 12!.
Using a 64-bit integer allows for larger factorials, such as 20!.
Using a floating-point data type allows for even larger factorials, but with reduced precision.
Printing the entire factorial may not be practical, so scienti...read more
Q24. What is your favorite coding language and why?
My favorite coding language is Python because of its simplicity and versatility.
Python has a clean and easy-to-read syntax, making it beginner-friendly.
It has a vast library of modules and frameworks for various applications.
Python is used in various fields such as web development, data science, and artificial intelligence.
It supports multiple programming paradigms such as object-oriented, functional, and procedural programming.
Python has a large and active community, providi...read more
Q25. Write a code for Octal to Decimal Conversion.
Code for Octal to Decimal Conversion
Start from the rightmost digit and move towards the leftmost digit
Multiply each digit with 8 raised to the power of its position
Add all the products obtained in the previous step to get the decimal equivalent
Q26. What are the advantages of OOPS?
OOPS provides modularity, reusability, and extensibility in software development.
Encapsulation ensures data security and prevents unauthorized access.
Inheritance allows for code reuse and reduces redundancy.
Polymorphism enables flexibility and allows for dynamic behavior.
Abstraction simplifies complex systems and hides implementation details.
OOPS promotes better organization and maintenance of code.
Examples: Java, C++, Python, Ruby, etc.
Q27. What is Exceptional Handling in Java?
Exceptional Handling is a mechanism to handle runtime errors in Java programs.
It is done using try-catch blocks.
It prevents the program from crashing due to errors.
It helps in debugging and maintaining the code.
Examples include NullPointerException, ArrayIndexOutOfBoundsException, etc.
Q28. What is a Friend Function in C++?
Friend function is a non-member function that has access to private and protected members of a class.
Declared inside the class but defined outside the class scope
Can access private and protected members of the class
Not a member of the class but has access to its private and protected members
Used to provide access to private or protected members to non-member functions or other classes
Example: friend void display(A);
Example: class A { friend void display(A); };
Q29. Which new technology did you learn recently?
I recently learned about React Native, a framework for building mobile apps using JavaScript.
React Native allows for cross-platform development, reducing the need for separate codebases for iOS and Android.
It uses a similar syntax to React, making it easy for web developers to transition to mobile development.
Some popular apps built with React Native include Facebook, Instagram, and Airbnb.
Q30. Why did you use a CLI library in your project?
CLI library was used for user interaction and ease of use.
CLI library provided a simple and intuitive way for users to interact with the project.
It allowed for easy input and output handling.
Examples include argparse in Python and Commander.js in Node.js.
It also made it easier to automate tasks through scripts.
Overall, it improved the user experience and made the project more accessible.
Q31. Small jumbelled words arranged into meaningful sentences
The question is asking for small jumbled words to be arranged into meaningful sentences.
Read each word carefully and try to identify any patterns or connections between them.
Look for common parts of speech such as nouns, verbs, and adjectives.
Try rearranging the words in different orders to see if any make sense.
Use context clues to help determine the meaning of each word.
Practice with similar exercises to improve your skills.
Q32. What is MultiThreading?
Multithreading is the ability of a CPU to execute multiple threads concurrently.
Multithreading allows for better utilization of CPU resources.
It can improve application performance by allowing multiple tasks to run simultaneously.
Multithreading can be implemented in various programming languages such as Java, C++, and Python.
Examples of multithreaded applications include web servers, video games, and media players.
Q33. Difference between polymorphism and abstraction.
Polymorphism is the ability of an object to take on many forms. Abstraction is the process of hiding implementation details.
Polymorphism allows objects of different classes to be treated as if they are of the same class.
Abstraction allows us to focus on the essential features of an object rather than its implementation details.
Polymorphism is achieved through method overriding and method overloading.
Abstraction is achieved through abstract classes and interfaces.
Example of po...read more
Q34. Remember small stories and recite and rephrase accordingly.
Recalling small stories and rephrasing them
Practice active listening to remember stories accurately
Use your own words to rephrase the story
Try to capture the main idea and important details
Use visualization techniques to help remember the story
Practice recalling stories with friends or family
Seating arrangement questions involve arranging people in a specific order based on given conditions.
Identify the total number of people to be seated
Understand the given conditions for seating arrangement
Use logic and elimination to determine the final seating arrangement
Q36. What are the technicalities related to the project(s).
The project involves developing a web-based application for managing inventory and sales.
The application will be built using Java and Spring framework.
It will have a user-friendly interface for adding, updating and deleting products.
The application will also generate reports on sales and inventory levels.
The database used will be MySQL.
The project will follow Agile methodology for development.
Q37. What are OOPS Concept?
OOPS stands for Object-Oriented Programming System. It is a programming paradigm based on the concept of objects.
OOPS is based on four main concepts: Encapsulation, Inheritance, Polymorphism, and Abstraction.
Encapsulation is the process of hiding the implementation details of an object from the outside world.
Inheritance allows a class to inherit properties and methods from another class.
Polymorphism allows objects of different classes to be treated as if they were of the same...read more
Q38. What is AI how you implement AI in your project
AI stands for Artificial Intelligence, which involves creating intelligent machines that can simulate human behavior and thinking.
AI is implemented in projects through machine learning algorithms like neural networks, decision trees, and support vector machines.
Natural language processing and computer vision are common AI techniques used in projects.
AI can be used in recommendation systems, chatbots, autonomous vehicles, and more.
Example: Implementing a chatbot using natural ...read more
Q39. What is your favorite programming language?
My favorite programming language is Python.
Python is a versatile and easy-to-learn language.
It has a simple and readable syntax, making it great for beginners.
Python has a large and active community, providing extensive libraries and frameworks.
It is widely used in various domains like web development, data analysis, and machine learning.
Python's extensive documentation and support make it a developer-friendly language.
Q40. Why did you switch from Mechanical to Software?
I switched from Mechanical to Software because I discovered my passion for coding and problem-solving.
Discovered passion for coding and problem-solving
Enjoyed programming courses and projects
Realized software development offered more opportunities for growth and innovation
Q41. Repeating sentences after an audio command.
Repeating sentences after an audio command
This is a common feature in voice assistants like Siri or Alexa
The device listens for a trigger word or phrase, then repeats the command back to the user
This can be useful for confirming that the device understood the command correctly
Q42. What is sorting in data structures
Sorting in data structures is the process of arranging data in a particular order, usually in ascending or descending order.
Sorting helps in organizing data for efficient searching and retrieval.
Common sorting algorithms include Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, Quick Sort, etc.
Example: Sorting an array of numbers in ascending order - [5, 2, 8, 1, 3] becomes [1, 2, 3, 5, 8].
Q43. What is foriegn Key and Primary key? What is normalisation? What is abstraction, polymorphism?
Primary key uniquely identifies each record in a table, while foreign key establishes a link between two tables. Normalization is the process of organizing data in a database to reduce redundancy. Abstraction is hiding the implementation details, and polymorphism allows objects to be treated as instances of their parent class.
Primary key uniquely identifies each record in a table
Foreign key establishes a link between two tables
Normalization reduces redundancy in database desi...read more
Q44. Machine Learning,Types and Real life examples
Machine learning is a subset of artificial intelligence that involves the development of algorithms and statistical models to perform specific tasks without explicit instructions.
Types of machine learning include supervised learning, unsupervised learning, and reinforcement learning.
Supervised learning involves training a model on labeled data to make predictions.
Unsupervised learning involves finding patterns in unlabeled data.
Reinforcement learning involves training a model...read more
Q45. Define OOPs Concept
OOPs (Object-Oriented Programming) is a programming paradigm that organizes code into objects with properties and behaviors.
OOPs focuses on creating reusable code by encapsulating data and methods within objects.
It emphasizes the concepts of inheritance, polymorphism, and encapsulation.
Objects are instances of classes, which define their structure and behavior.
Inheritance allows classes to inherit properties and methods from other classes.
Polymorphism enables objects to take ...read more
Q46. string using loop
To create a string using loop
Declare an empty string variable
Use a loop to concatenate desired strings to the variable
Use the loop condition to control the number of iterations
Q47. Write a basic code in C++
A basic code in C++
Use the 'int main()' function as the entry point of the program
Declare an array of strings using the syntax 'string arrayName[size]'
Initialize the array with values
Access and manipulate the elements of the array using indexing
Q48. Explain DBMS concept to a four year child
DBMS is like a big box where we keep all our information organized so we can find it easily.
DBMS stands for Database Management System
It helps us store and organize information in a structured way
We can easily search, add, delete or modify information in DBMS
Examples of DBMS are MySQL, Oracle, SQL Server
Q49. steps in software development life cycle
Software development life cycle involves planning, designing, coding, testing, and maintenance.
Planning: Define project scope, requirements, and objectives.
Design: Create a detailed plan for the software solution.
Coding: Write the code according to the design.
Testing: Verify that the software meets the requirements and is free of defects.
Maintenance: Make changes to the software to keep it up-to-date and functioning properly.
Q50. Difference between c and cpp
C is a procedural programming language while C++ is an object-oriented programming language.
C is a subset of C++.
C does not support classes and objects, while C++ does.
C++ supports function overloading and operator overloading, which C does not.
C++ has a more extensive standard library compared to C.
C++ allows for both procedural and object-oriented programming paradigms.
Q51. Reverse an Array
Reverse an array of strings.
Create a new empty array
Loop through the original array in reverse order
Push each element into the new array
Return the new array
Q52. Pronounciation of words
Pronunciation of words is important for effective communication and understanding.
Practice pronouncing difficult words regularly
Use online resources like dictionaries or pronunciation guides
Ask for feedback from native speakers or language teachers
Q53. Explain project
The project was a web application for managing inventory and sales for a retail store.
Developed using Java and Spring framework
Implemented CRUD operations for managing products and customers
Integrated with payment gateway for online transactions
Generated reports for sales and inventory management
Deployed on AWS EC2 instance
Q54. Favourite language
My favourite language is Python.
Python is easy to learn and has a simple syntax.
It has a large community and a vast number of libraries.
Python is versatile and can be used for web development, data analysis, machine learning, and more.
Q55. 3. Concepts of OOPS
OOPS stands for Object-Oriented Programming System. It is a programming paradigm based on the concept of objects.
OOPS focuses on creating objects that interact with each other to solve a problem
It emphasizes on encapsulation, inheritance, and polymorphism
Encapsulation is the process of hiding the implementation details of an object from the outside world
Inheritance allows a class to inherit properties and methods from another class
Polymorphism allows objects to take on multip...read more
Q56. Accademic project?
Developed a web-based project management system using Java and MySQL.
Implemented user authentication and authorization using Spring Security.
Utilized Hibernate for database operations and RESTful APIs for communication.
Designed a responsive front-end using HTML, CSS, and JavaScript.
Tested the application using JUnit and Selenium for automated testing.
Q57. Jumbled Sentence
The jumbled sentence is a set of words that are not in the correct order. The task is to rearrange the words to form a meaningful sentence.
Identify the subject, verb, and object in the sentence.
Look for connecting words like conjunctions or prepositions to help determine the correct order.
Consider the context or topic of the sentence to make logical sense of the words.
Rearrange the words in a way that makes grammatical sense and forms a coherent sentence.
More about working at Accenture
Top HR Questions asked in Marksans Pharma
Interview Process at Marksans Pharma
Top Associate Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month