Cadence Design Systems
10+ Khanco Interview Questions and Answers
Q1. Find All Pairs with Given Sum
Given an integer array arr
and an integer Sum
, count and return the total number of pairs in the array whose elements add up to the given Sum
.
Input:
The first line contains two sp...read more
Count and return the total number of pairs in the array whose elements add up to a given sum.
Use a hashmap to store the frequency of each element in the array.
Iterate through the array and for each element, check if (Sum - current element) exists in the hashmap.
Increment the count of pairs if the complement exists in the hashmap.
Q2. Minimum Number of Jumps Problem
Given an array ARR
of N
integers, determine the minimum number of jumps required to reach the last index of the array (i.e., N - 1
). From any index i
, you can jump to an index i ...read more
The problem involves finding the minimum number of jumps required to reach the last index of an array, where each element indicates the maximum distance that can be jumped from that position.
Use a greedy approach to keep track of the farthest reachable index and the current end of the jump.
Iterate through the array, updating the farthest reachable index and incrementing the jump count when necessary.
Return the jump count as the minimum number of jumps needed to reach the last...read more
Q3. Two Teams (Check Whether Graph is Bipartite or Not)
Determine if a given undirected graph can be divided into exactly two disjoint cliques. Print 1 if possible, otherwise print 0.
Input:
The first line contains...read more
Check if a given undirected graph can be divided into exactly two disjoint cliques.
Create an adjacency list to represent the graph
Use BFS or DFS to check if the graph is bipartite
If the graph is bipartite, it can be divided into two disjoint cliques
Q4. Maximum Length Pair Chain Problem
You are provided with 'N' pairs of integers, where the first number in each pair is less than the second number, i.e., in pair (a, b) -> a < b. A pair chain is defined as a seq...read more
Find the length of the longest pair chain that can be formed using the provided pairs.
Sort the pairs based on the second number in each pair.
Iterate through the sorted pairs and keep track of the maximum chain length.
Update the maximum chain length based on the conditions given in the problem statement.
Diamond Problem is a common issue in multiple inheritance in C++ where a class inherits from two classes that have a common base class.
Diamond Problem occurs when a class inherits from two classes that have a common base class, leading to ambiguity in accessing members.
It can be resolved in C++ using virtual inheritance, where the common base class is inherited virtually to avoid duplicate copies of base class members.
Example: class A is inherited by classes B and C, and then...read more
Data abstraction is the process of hiding implementation details and showing only the necessary features of an object.
Data abstraction can be achieved through classes and objects in object-oriented programming.
It involves creating a class with private data members and public methods to access and modify those data members.
By using data abstraction, users can interact with objects without needing to know the internal workings of the object.
For example, a car object may have me...read more
Multitasking involves running multiple tasks concurrently, while multithreading allows multiple threads within a single process to run concurrently.
Multitasking allows multiple processes to run concurrently on a single processor, switching between them quickly.
Multithreading allows multiple threads within a single process to run concurrently, sharing resources like memory and CPU time.
Multitasking is at the process level, while multithreading is at the thread level.
Example: A...read more
Design a system like Pastebin for sharing text snippets
Use a web application framework like Django or Flask for the backend
Store text snippets in a database like MySQL or MongoDB
Generate unique URLs for each snippet to share with others
Implement features like syntax highlighting, expiration time, and password protection
Consider implementing user accounts for managing and organizing snippets
TCP/IP is a set of rules governing the exchange of data over the internet.
TCP/IP stands for Transmission Control Protocol/Internet Protocol.
It is a suite of communication protocols used to connect devices on the internet.
TCP ensures that data is delivered reliably and in order, while IP handles the addressing and routing of data packets.
Examples of TCP/IP applications include web browsing (HTTP), email (SMTP), and file transfer (FTP).
Friend functions in C++ are functions that are not members of a class but have access to its private and protected members.
Friend functions are declared inside a class with the keyword 'friend'.
They can access private and protected members of the class they are friends with.
Friend functions are not member functions of the class.
They can be standalone functions or functions of another class.
Example: friend void displayDetails(Student);
DHCP Protocol is used to automatically assign IP addresses to devices on a network.
DHCP stands for Dynamic Host Configuration Protocol
It allows devices to obtain IP addresses and other network configuration information dynamically
DHCP servers assign IP addresses to devices for a specific lease period
DHCP uses a client-server model where the client requests an IP address and the server assigns one
DHCP uses UDP port 67 for the server and UDP port 68 for the client
Top SDE-2 Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month