Filter interviews by
Implement max() function to find the maximum element in a stack with optimized time and space complexity.
Use an additional stack to keep track of the maximum element at each step.
When pushing an element onto the stack, compare it with the top element of the maximum stack and push the larger one.
When popping an element from the stack, also pop the top element from the maximum stack if they are equal.
The top element...
Stacks are a data structure that follows the Last-In-First-Out (LIFO) principle.
Stacks have two main operations: push (adds an element to the top) and pop (removes the top element).
Stacks can be implemented using arrays or linked lists.
Common applications of stacks include function call stack, undo/redo operations, and expression evaluation.
Example: A stack of books, where the last book placed is the first one to ...
The sum of even numbers in the Fibonacci series is calculated.
Generate the Fibonacci series up to a given limit
Iterate through the series and check if each number is even
If the number is even, add it to the sum
Return the sum of the even numbers
Print Fibonacci series less than or equal to 1000.
Start with two variables, a and b, initialized to 0 and 1 respectively.
Print a and update a to the value of b, and b to the sum of the previous a and b.
Repeat until a exceeds 1000.
An abstract class is a class that cannot be instantiated and is meant to be subclassed.
An abstract class can have both abstract and non-abstract methods.
It can provide a common interface for its subclasses.
Subclasses of an abstract class must implement all the abstract methods.
Abstract classes can have constructors.
An abstract class cannot be instantiated directly, but its subclasses can be.
Check if given tree is BST or not
A binary tree is a BST if the value of each node is greater than all the values in its left subtree and less than all the values in its right subtree
Perform an in-order traversal of the tree and check if the values are in ascending order
Alternatively, for each node, check if its value is within the range defined by its left and right subtrees
Delete nodes in linkedlist with greater value on right side
Traverse the linked list from right to left
Compare each node with the maximum value seen so far
If the current node has a greater value, delete it
Update the maximum value seen so far
Runtime polymorphism is when the method to be executed is determined at runtime, while compile-time polymorphism is determined at compile-time.
Runtime polymorphism is achieved through method overriding.
Compile-time polymorphism is achieved through method overloading.
Runtime polymorphism is also known as dynamic polymorphism.
Compile-time polymorphism is also known as static polymorphism.
Runtime polymorphism is asso...
OOP is a programming paradigm that organizes code into objects with properties and behaviors.
OOP stands for Object-Oriented Programming.
It focuses on creating reusable code by organizing it into objects.
Objects have properties (attributes) and behaviors (methods).
Encapsulation, inheritance, and polymorphism are key principles of OOP.
Example: In Java, a class represents an object with its properties and methods.
Virtual functions are functions in a base class that can be overridden by derived classes to provide different implementations.
Virtual functions are declared in a base class and can be overridden in derived classes.
They allow polymorphism, where a pointer to a base class can invoke different derived class implementations.
Virtual functions are resolved at runtime based on the actual object type.
They are used to ach...
posted on 14 Oct 2015
Prims and Kruskal's algorithms are used to find the minimum spanning tree in a graph.
Prims algorithm starts with a single vertex and adds the minimum weight edge to the tree until all vertices are included.
Kruskal's algorithm starts with all vertices as separate trees and merges them by adding the minimum weight edge until all vertices are included.
Both algorithms have a time complexity of O(E log V) where E is the num...
Delete nodes in a linked list which have greater value on right side
Traverse the linked list and compare each node with its right side node
If the current node's value is less than its right side node, delete the current node
Repeat the process until the end of the linked list is reached
Code for reversing a linked list
Create a new empty linked list
Traverse the original linked list and insert each node at the beginning of the new list
Return the new list
Methods are functions that perform a specific task, while constructors are special methods that initialize objects.
Constructors have the same name as the class they belong to.
Constructors are called automatically when an object is created.
Constructors can be overloaded with different parameters.
Methods can be called multiple times with different arguments.
Methods can have a return type, while constructors do not.
posted on 30 Sep 2015
Find all permutations of a given string.
Use recursion to swap each character with every other character in the string.
Repeat the process for each substring.
Add the permutation to an array.
Given an array of size 98 with natural numbers from 1-100 but 2 numbers are missing, find them.
Calculate the sum of all numbers from 1-100 using the formula n(n+1)/2
Calculate the sum of all numbers in the array
Subtract the sum of array from the sum of all numbers to get the sum of missing numbers
Find the missing numbers by iterating through the array and checking which numbers are not present
Check if a binary tree is a binary search tree or not.
Traverse the tree in-order and check if the elements are in sorted order.
Check if the left child is less than the parent and the right child is greater than the parent.
Use recursion to check if all the subtrees are BSTs.
Maintain a range for each node and check if the node value is within that range.
Detect and remove cycle in a linked list
Use two pointers, one slow and one fast, to detect a cycle
Once a cycle is detected, move one pointer to the head and iterate both pointers until they meet again
Set the next node of the last node in the cycle to null to remove the cycle
Convert a number to its hexadecimal form
Use the built-in function to convert the number to hexadecimal
Alternatively, use the algorithm to convert the number to hexadecimal manually
Ensure to handle negative numbers appropriately
Priority scheduling is a scheduling algorithm where processes are assigned priorities and executed based on their priority level.
Preemptive priority scheduling allows a higher priority process to interrupt a lower priority process that is currently running.
Non-preemptive priority scheduling allows a higher priority process to wait until the lower priority process finishes executing.
A low priority process can preempt a ...
Singleton class is a class that can only have one instance at a time.
Singleton pattern is used when we need to ensure that only one instance of a class is created and that instance can be accessed globally.
The constructor of a singleton class is always private to prevent direct instantiation.
A static method is used to access the singleton instance.
Example: public class Singleton { private static Singleton instance = ne...
Develop tic-tac-toe game using OOPS concepts in CPP.
Create a class for the game board
Create a class for the players
Create a class for the game logic
Use inheritance and polymorphism for game objects
Implement functions for checking win/lose/draw conditions
posted on 14 Oct 2015
posted on 30 Aug 2016
I appeared for an interview in Jan 2016.
Delete nodes in linkedlist with greater value on right side
Traverse the linked list from right to left
Compare each node with the maximum value seen so far
If the current node has a greater value, delete it
Update the maximum value seen so far
Check if given tree is BST or not
A binary tree is a BST if the value of each node is greater than all the values in its left subtree and less than all the values in its right subtree
Perform an in-order traversal of the tree and check if the values are in ascending order
Alternatively, for each node, check if its value is within the range defined by its left and right subtrees
Adhoc string questions often test manipulation, searching, or pattern recognition skills in programming.
String reversal: Reverse a string using slicing. Example: 'hello' -> 'olleh'.
Palindrome check: Determine if a string reads the same forwards and backwards. Example: 'racecar' is a palindrome.
Substring search: Find if one string is a substring of another. Example: 'cat' in 'concatenation' returns True.
Character fre...
OOP is a programming paradigm that organizes code into objects with properties and behaviors.
OOP stands for Object-Oriented Programming.
It focuses on creating reusable code by organizing it into objects.
Objects have properties (attributes) and behaviors (methods).
Encapsulation, inheritance, and polymorphism are key principles of OOP.
Example: In Java, a class represents an object with its properties and methods.
Runtime polymorphism is when the method to be executed is determined at runtime, while compile-time polymorphism is determined at compile-time.
Runtime polymorphism is achieved through method overriding.
Compile-time polymorphism is achieved through method overloading.
Runtime polymorphism is also known as dynamic polymorphism.
Compile-time polymorphism is also known as static polymorphism.
Runtime polymorphism is associate...
Virtual functions are functions in a base class that can be overridden by derived classes to provide different implementations.
Virtual functions are declared in a base class and can be overridden in derived classes.
They allow polymorphism, where a pointer to a base class can invoke different derived class implementations.
Virtual functions are resolved at runtime based on the actual object type.
They are used to achieve ...
An abstract class is a class that cannot be instantiated and is meant to be subclassed.
An abstract class can have both abstract and non-abstract methods.
It can provide a common interface for its subclasses.
Subclasses of an abstract class must implement all the abstract methods.
Abstract classes can have constructors.
An abstract class cannot be instantiated directly, but its subclasses can be.
Inheritance is a mechanism in object-oriented programming where a class inherits properties and behaviors from another class.
Inheritance allows code reuse and promotes code organization.
There are different types of inheritance: single inheritance, multiple inheritance, multilevel inheritance, hierarchical inheritance, and hybrid inheritance.
Single inheritance involves a class inheriting from a single base class.
Multipl...
Print Fibonacci series less than or equal to 1000.
Start with two variables, a and b, initialized to 0 and 1 respectively.
Print a and update a to the value of b, and b to the sum of the previous a and b.
Repeat until a exceeds 1000.
The sum of even numbers in the Fibonacci series is calculated.
Generate the Fibonacci series up to a given limit
Iterate through the series and check if each number is even
If the number is even, add it to the sum
Return the sum of the even numbers
Explore unconventional methods to achieve sub-linear time complexity for the given problem.
Use hashing to store previously computed results, allowing O(1) lookups.
Implement a divide-and-conquer strategy to reduce problem size recursively.
Consider using a probabilistic approach, like Bloom filters, for approximate results.
Utilize parallel processing to handle multiple data segments simultaneously.
Stacks are a data structure that follows the Last-In-First-Out (LIFO) principle.
Stacks have two main operations: push (adds an element to the top) and pop (removes the top element).
Stacks can be implemented using arrays or linked lists.
Common applications of stacks include function call stack, undo/redo operations, and expression evaluation.
Example: A stack of books, where the last book placed is the first one to be re...
Implement max() function to find the maximum element in a stack with optimized time and space complexity.
Use an additional stack to keep track of the maximum element at each step.
When pushing an element onto the stack, compare it with the top element of the maximum stack and push the larger one.
When popping an element from the stack, also pop the top element from the maximum stack if they are equal.
The top element of t...
Top trending discussions
I appeared for an interview before May 2022.
Basic on PHP and Javascript should be clear
Laravel framework based questions
Algo, basic Javascript
Queue can be implemented using two stacks by maintaining the order of elements in the stacks.
Create two stacks, let's call them stack1 and stack2
When an element is enqueued, push it to stack1
When an element is dequeued, pop all elements from stack1 and push them to stack2
Pop the top element from stack2 and return it as the dequeued element
If stack2 is empty, repeat step 3
To get the front element of the queue, peek the ...
Retrieve the 2nd highest and nth highest marks from a student table using SQL queries.
Use the DISTINCT keyword to avoid duplicate marks.
For the 2nd highest marks: SELECT DISTINCT Marks FROM student ORDER BY Marks DESC LIMIT 1 OFFSET 1;
For nth highest marks: SELECT DISTINCT Marks FROM student ORDER BY Marks DESC LIMIT 1 OFFSET n-1; (replace n with the desired number)
Example for 2nd highest: If Marks are 90, 85, 90, 80, ...
Left join returns all records from left table and matching records from right table. Full outer join returns all records from both tables.
Left join is used to combine two tables based on a common column.
In left join, all records from the left table are returned along with matching records from the right table.
If there is no match in the right table, NULL values are returned.
Example: SELECT * FROM table1 LEFT JOIN table...
Magic functions are special methods in PHP that start with __. Autoloading is a way to automatically load classes.
Magic functions are used to handle certain events in PHP, such as object creation or property access.
Autoloading allows PHP to automatically load classes when they are needed, without requiring manual includes.
Magic functions can be used in conjunction with autoloading to dynamically load classes or handle ...
Given three sorted arrays, find common elements.
Create three pointers to traverse each array
Compare the elements at the pointers and move the pointer of the smallest element
If all pointers point to the same element, add it to the result and move all pointers
Repeat until any pointer reaches the end of its array
Check if a number is a power of 2 or not.
A power of 2 has only one bit set in its binary representation.
Use bitwise AND operator to check if the number is a power of 2.
If n is a power of 2, then n & (n-1) will be 0.
I applied via Referral
I haven't contributed to open source due to time constraints and focusing on personal projects and learning new technologies.
Time Constraints: Balancing work, personal projects, and learning new technologies has limited my availability.
Focus on Personal Projects: I've been dedicated to developing my own applications, such as a task management tool.
Learning New Technologies: I prioritized mastering frameworks like React...
I appeared for an interview before Feb 2021.
Round duration - 60 minutes
Round difficulty - Easy
It comprised of general aptitude questions and two coding questions. It was an offline test.
Given an integer N
, find all possible placements of N
queens on an N x N
chessboard such that no two queens threaten each other.
A queen can attack another queen if they ar...
The N Queens Problem involves finding all possible placements of N queens on an N x N chessboard where no two queens threaten each other.
Use backtracking algorithm to explore all possible configurations.
Keep track of rows, columns, and diagonals to ensure queens do not attack each other.
Generate and print valid configurations where queens are placed safely.
Consider constraints and time limit for efficient solution.
Exam...
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
The first line contains an integer 'T' representing the n...
Sort an integer array containing only 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of the positions of 0s, 1s, and 2s in the array.
Iterate through the array and swap elements based on the values encountered.
Achieve sorting in a single scan over the array without using any extra space.
Round duration - 60 minutes
Round difficulty - Easy
After having a technical discussion about my CV. He gave me two questions to code.
Ninja has to determine all the distinct substrings of size two that can be formed from a given string 'STR' comprising only lowercase alphabetic characters. These su...
Find all unique contiguous substrings of size two from a given string.
Iterate through the string and extract substrings of size two
Use a set to store unique substrings
Return the set as an array of strings
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 ...
Detect if a singly linked list forms a cycle by checking if a node's next points back to a previous node.
Traverse the linked list using two pointers, one moving one step at a time and the other moving two steps at a time.
If the two pointers meet at any point, there is a cycle in the linked list.
If one of the pointers reaches the end of the list (null), there is no cycle.
Round duration - 30 minutes
Round difficulty - Easy
This was supposed to be the HR round but out of surprise the interviewer started by giving me a question to code.
After I approached this question with the right solution he just asked about my family. After that he said to wait. After half an hour the results were announced. A total of three students were hired and I was amongst one of them.
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.
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.
Return the valid combinations as an array of strings.
Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.
Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.
Some of the top questions asked at the Carwale SDE (Software Development Engineer) interview -
based on 2 reviews
Rating in categories
Accounts Manager
138
salaries
| ₹3 L/yr - ₹5.8 L/yr |
Key Account Manager
97
salaries
| ₹3.3 L/yr - ₹7.3 L/yr |
Regional Manager
35
salaries
| ₹4 L/yr - ₹10.2 L/yr |
Product Manager
27
salaries
| ₹12 L/yr - ₹31 L/yr |
Software Development Engineer 1
22
salaries
| ₹6.5 L/yr - ₹14.9 L/yr |
MagicBricks
Netmeds.com
Practo
Tracxn