"Basic Approach
As BST inorder traversal will result in a sequence of increasing order. Store that order in a vector and get the k-1 index to get the Kth smallest element, similarly access the N-K+1 th element will be the Kth largest element
Time Complexity: O(n)
Space Complexity O(n)
Space Optimized Approach
For Kth smallest , start inorder traversal, and keep a counter, decrement the counter when you access the node element. When the counter turns 0 that elementwill be the Kth smal"
Saurabh S. - "Basic Approach
As BST inorder traversal will result in a sequence of increasing order. Store that order in a vector and get the k-1 index to get the Kth smallest element, similarly access the N-K+1 th element will be the Kth largest element
Time Complexity: O(n)
Space Complexity O(n)
Space Optimized Approach
For Kth smallest , start inorder traversal, and keep a counter, decrement the counter when you access the node element. When the counter turns 0 that elementwill be the Kth smal"See full answer
"In Python, an "oops" (Object-Oriented Programming) concept refers to a programming paradigm that is based on the idea of objects and classes. OOP allows developers to model real-world concepts and create reusable code blocks through the use of inheritance, polymorphism, and encapsulation.
Here are some common OOP concepts in Python:
Class: A class is a blueprint for creating objects. It defines the attributes and behaviors that objects of that class will have.
Object: An object is an insta"
Anonymous Flamingo - "In Python, an "oops" (Object-Oriented Programming) concept refers to a programming paradigm that is based on the idea of objects and classes. OOP allows developers to model real-world concepts and create reusable code blocks through the use of inheritance, polymorphism, and encapsulation.
Here are some common OOP concepts in Python:
Class: A class is a blueprint for creating objects. It defines the attributes and behaviors that objects of that class will have.
Object: An object is an insta"See full answer
"Imagine there's a new toy you've always wanted, but it's not quite perfect. Maybe it's missing a feature you'd love, or it's a bit too complex to use. That's where a product manager, or PM, comes in!
Think of a PM like the captain of a shipbuilding this amazing toy. They work with different teams, like the designers who make it look cool, the engineers who build it, and the marketers who tell everyone about it. They listen to people like you, who use the toy, to understand what they like and wha"
Deepak M. - "Imagine there's a new toy you've always wanted, but it's not quite perfect. Maybe it's missing a feature you'd love, or it's a bit too complex to use. That's where a product manager, or PM, comes in!
Think of a PM like the captain of a shipbuilding this amazing toy. They work with different teams, like the designers who make it look cool, the engineers who build it, and the marketers who tell everyone about it. They listen to people like you, who use the toy, to understand what they like and wha"See full answer
Technical
Behavioral
🧠Want an expert answer to a question? Saving questions lets us know what content to make next.
"Binary search is commonly used for searching elements in a sorted array. Most searching algorithms take O(n) time, but binary search operates in O(log(n)) time complexity.
function binarySearch(arr, target) {
let first = 0;
let last = arr.length - 1; // Adjusted to correctly represent the last index
while (first target) {
last = mid - 1;
}
"
Satyam S. - "Binary search is commonly used for searching elements in a sorted array. Most searching algorithms take O(n) time, but binary search operates in O(log(n)) time complexity.
function binarySearch(arr, target) {
let first = 0;
let last = arr.length - 1; // Adjusted to correctly represent the last index
while (first target) {
last = mid - 1;
}
"See full answer
"This is a Technical question. It tests your ability to understand high level technical concepts. Even though your job won't have any coding involved, you'll still need to understand these concepts. Being able to cover all these topics with clarity communicates confidence in your interviewer.
Unfortunately, there's no formula for technical questions, but some general tips are:
Use analogies when you can
Break your solution into clear, bite-size steps
Don't be afraid to use examples to b"
Exponent - "This is a Technical question. It tests your ability to understand high level technical concepts. Even though your job won't have any coding involved, you'll still need to understand these concepts. Being able to cover all these topics with clarity communicates confidence in your interviewer.
Unfortunately, there's no formula for technical questions, but some general tips are:
Use analogies when you can
Break your solution into clear, bite-size steps
Don't be afraid to use examples to b"See full answer
"Race Condition i,e multiple threads modifying simultaneously can lead to data inconsistency
Operations like putIfAbsent() or computeIfAbsent() are not atomoic i.e duplicate entries or missing updates when multiple threads perform operations
Data Corruption : during resizing of a hashmap by a thread, if another thread is accessing the same data , buckets can get corrupted, leading to a loss of data"
Sue G. - "Race Condition i,e multiple threads modifying simultaneously can lead to data inconsistency
Operations like putIfAbsent() or computeIfAbsent() are not atomoic i.e duplicate entries or missing updates when multiple threads perform operations
Data Corruption : during resizing of a hashmap by a thread, if another thread is accessing the same data , buckets can get corrupted, leading to a loss of data"See full answer
"That I had not been a PM for a formal ML product. But good models need sound data and my five years of sql writing and ensuring that DWHs and marts had the data they needed for reporting would be very relevant"
Tony C. - "That I had not been a PM for a formal ML product. But good models need sound data and my five years of sql writing and ensuring that DWHs and marts had the data they needed for reporting would be very relevant"See full answer
"I try to solve this initially using quick select where will take a pivot element and position the remaining elements and check if the current index is answer or not and continue the same but it requires o(n*n), but interviewee is expecting the best from me, so at the end i tried solving using heaps where will check the difference between k and n-k to use min or max heap after that we will heap the array, and will keep popping the element k-1 and return the peek one which leads to answer."
Mourya C. - "I try to solve this initially using quick select where will take a pivot element and position the remaining elements and check if the current index is answer or not and continue the same but it requires o(n*n), but interviewee is expecting the best from me, so at the end i tried solving using heaps where will check the difference between k and n-k to use min or max heap after that we will heap the array, and will keep popping the element k-1 and return the peek one which leads to answer."See full answer