Add office photos
Employer?
Claim Account for FREE

Salesforce

4.0
based on 853 Reviews
Video summary
Filter interviews by

10+ Sanity Pharma Interview Questions and Answers

Updated 5 Feb 2024
Popular Designations

Q1. 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

Ans.

Generate all possible combinations of balanced parentheses for a given number of pairs.

  • Use recursion to generate all possible combinations of balanced parentheses.

  • Keep track of the number of open and close parentheses used in each combination.

  • Terminate recursion when the number of open and close parentheses used equals the given number of pairs.

Add your answer

Q2. Longest Happy String Problem Statement

Given three non-negative integers X, Y, and Z, determine the longest happy string. A happy string is defined as a string that contains only the letters 'a', 'b', and 'c' w...read more

Ans.

The problem involves constructing the longest happy string with given constraints on the frequency of 'a', 'b', and 'c'.

  • Iterate through the characters 'a', 'b', 'c' in decreasing order of their frequencies

  • Append the character with the highest frequency that does not create a substring of 3 same characters

  • Repeat until all characters are used up or the string reaches the desired length

Add your answer

Q3. Problem Description

Given a graph with 'N' nodes and 'M' unidirectional edges, along with two integers 'S' and 'D' representing the source and destination respectively, your task is to find all possible paths f...read more

Ans.

Find all possible paths from a source node to a destination node in a graph with unique nodes.

  • Create a graph using the given nodes and edges

  • Implement a depth-first search (DFS) algorithm to find all paths from source to destination

  • Ensure that the nodes in the paths are unique and print them in lexicographically sorted order

Add your answer

Q4. Ninja and Chocolates Problem Statement

Ninja is hungry and wants to eat his favorite chocolates, but his mother won't let him because he has already eaten enough. There are 'N' jars filled with chocolates. His ...read more

Ans.

Find the minimum eating speed required for a ninja to consume all chocolates within a given time limit.

  • Iterate through possible eating speeds to find the minimum speed that allows the ninja to consume all chocolates within the given time limit.

  • Calculate the total number of chocolates to be consumed and divide it by the time limit to get the minimum eating speed.

  • Handle cases where a jar has fewer chocolates than the eating speed by consuming all available chocolates from that ...read more

Add your answer
Discover Sanity Pharma interview dos and don'ts from real experiences

Q5. Construct the Lexicographically Largest Valid Sequence

You are provided with a positive integer N. The goal is to generate the lexicographically largest sequence of length 2*N - 1, containing integers ranging f...read more

Ans.

Generate lexicographically largest valid sequence of length 2*N - 1 with specific constraints.

  • Start with the largest numbers and place them at the ends to maximize lexicographical order.

  • Place the number 1 in the middle to satisfy the condition of appearing exactly once.

  • Determine the positions of other numbers based on their distance requirements.

  • Iterate through the sequence and fill in the numbers based on the constraints.

  • Ensure that each number from 2 to N appears exactly tw...read more

Add your answer

Q6. Cycle Detection in a Singly Linked List

Determine if a given singly linked list of integers forms a cycle or not.

A cycle in a linked list occurs when a node's next points back to a previous node in the list. T...read more

Ans.

Detect if a singly linked list forms a cycle by checking if a node's next pointer points back to a previous node.

  • Use Floyd's Tortoise and Hare algorithm to detect a cycle in O(N) time complexity and O(1) space complexity.

  • Start with two pointers, slow and fast, moving at different speeds. If they meet at some point, there is a cycle.

  • If the fast pointer reaches the end of the list (null), there is no cycle.

  • Example: For input 3 2 0 -4 -1, with pos 1, the linked list forms a cycl...read more

Add your answer
Are these interview questions helpful?

Q7. Pair with Given Sum in a Balanced BST Problem Statement

You are given the ‘root’ of a Balanced Binary Search Tree and an integer ‘target’. Your task is to determine if there exists any pair of nodes such that t...read more

Ans.

Given a Balanced BST and a target integer, determine if there exists a pair of nodes with sum equal to the target.

  • Traverse the BST in-order to get a sorted array of values.

  • Use two pointers approach to find the pair with sum equal to target.

  • Consider edge cases like negative numbers and duplicates.

  • Time complexity should be O(n) and space complexity O(n).

Add your answer

Q8. Zuma Game Problem Statement

You have a string of balls on the table called BOARD and several balls in your hand represented by the string hand. The balls can be of the colors red(R), blue(B), green(G), white(W)...read more

Ans.

Determine the minimum number of insertions required to empty the board in Zuma game problem.

  • Check if it's possible to empty the board by trying all possible combinations of inserting balls from hand.

  • Use backtracking algorithm to simulate the game and find the minimum number of insertions required.

  • Handle edge cases like when the board cannot be emptied or when the hand is empty.

  • Consider optimizing the algorithm by pruning branches that cannot lead to a solution.

  • Example: For BO...read more

Add your answer
Share interview questions and help millions of jobseekers 🌟
Q9. What is the difference between Early Binding and Late Binding in C++?
Ans.

Early binding is resolved at compile time while late binding is resolved at runtime in C++.

  • Early binding is also known as static binding, where the function call is resolved at compile time based on the type of the object.

  • Late binding is also known as dynamic binding, where the function call is resolved at runtime based on the actual type of the object.

  • Early binding is faster as the function call is directly linked during compilation.

  • Late binding allows for polymorphism and i...read more

Add your answer
Q10. What is the difference between a virtual function and an abstract class in Object-Oriented Programming?
Ans.

Virtual functions can be overridden in derived classes, while abstract classes cannot be instantiated directly.

  • Virtual functions are declared using the 'virtual' keyword and can be overridden in derived classes.

  • Abstract classes cannot be instantiated and may contain one or more pure virtual functions.

  • An abstract class can have virtual functions, but a virtual function does not make a class abstract.

  • Example: Shape is an abstract class with a pure virtual function 'calculateAre...read more

Add your answer
Q11. Design a platform similar to LinkedIn. What are the key features and architecture you would implement?
Ans.

Design a platform similar to LinkedIn with key features and architecture

  • Key Features: user profiles, connections, job postings, messaging, news feed, groups

  • Architecture: microservices, cloud storage, scalable database, AI for recommendations

  • Security: encryption, secure authentication, data privacy controls

  • User Experience: intuitive UI/UX, mobile app support, notifications

  • Monetization: premium subscriptions, advertising, job posting fees

Add your answer
Q12. What is meant by multitasking and multithreading in operating systems?
Ans.

Multitasking refers to the ability of an operating system to run multiple tasks concurrently, while multithreading involves executing multiple threads within a single process.

  • Multitasking allows multiple processes to run simultaneously on a single processor, switching between them quickly.

  • Multithreading enables a single process to execute multiple threads concurrently, improving performance and responsiveness.

  • Multitasking is at the process level, while multithreading is at th...read more

Add your answer

More about working at Salesforce

#12 Best Mid-Sized Company - 2022
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Sanity Pharma

based on 7 interviews
1 Interview rounds
Coding Test Round
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Interview Questions from Similar Companies

3.5
 • 54 Interview Questions
3.3
 • 46 Interview Questions
3.7
 • 45 Interview Questions
3.7
 • 22 Interview Questions
3.5
 • 13 Interview Questions
3.0
 • 11 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter