Whitehat jr
Sparrows Group Interview Questions and Answers
Q1. Add 2 linked list and return final linked list
Add 2 linked lists and return final linked list
Create a new linked list to store the sum
Traverse both linked lists simultaneously and add the corresponding nodes
Handle carry over while adding nodes
If one linked list is longer than the other, add the remaining nodes to the sum list
Q2. Stock buy sell problem to maximize profit.
Algorithm to maximize profit by buying and selling stocks.
Iterate through the array of stock prices
Keep track of the minimum price seen so far
Calculate the profit if sold at current price
Update maximum profit seen so far
Return maximum profit
Q3. Find a Element in rotated sorted array
Finding an element in a rotated sorted array.
Use binary search to find the pivot point where the array is rotated.
Determine which half of the array the target element is in.
Perform binary search on that half of the array to find the target element.
Handle edge cases such as when the target element is at the pivot point.
Q4. Explain CSS box model. Do padding and margin apply to inline elements?
CSS box model defines how elements are displayed and spaced on a webpage. Padding and margin apply to block elements only.
CSS box model consists of content, padding, border, and margin
Padding is the space between the content and the border
Margin is the space outside the border
Inline elements do not have padding or margin, only horizontal space
Block elements can have padding and margin
Q5. how does JavaScript asynchronous model work
JavaScript asynchronous model allows non-blocking code execution by using callbacks and promises.
JavaScript uses an event loop to handle asynchronous operations.
Callbacks are functions passed as arguments to other functions and executed when the operation is complete.
Promises are objects that represent the eventual completion or failure of an asynchronous operation.
Async/await is a newer syntax that allows writing asynchronous code in a synchronous style.
Example: setTimeout()...read more
Q6. Difference between arrow functions and regular ones.
Arrow functions are shorter syntax for writing function expressions.
Arrow functions do not have their own 'this' keyword.
Arrow functions cannot be used as constructors.
Arrow functions do not have the 'arguments' object.
Arrow functions are more concise and easier to read.
Regular functions are better for methods and constructors.
Q7. Find word in matrix.
Given a matrix of characters and a word, find if the word exists in the matrix.
Traverse the matrix and check if the first letter of the word matches any cell.
If it does, check if the adjacent cells match the next letter of the word.
Repeat until the entire word is found or no match is found.
Q8. Difference between var, let, const.
var, let, and const are all used to declare variables in JavaScript, but they have different scoping rules and behaviors.
var has function scope and can be redeclared and reassigned
let has block scope and can be reassigned but not redeclared
const has block scope and cannot be reassigned or redeclared
Use const for values that won't change, let for values that will, and avoid var
Q9. List in react and the input box
Answer on how to list in react and the input box
Use the map function to create a list in React
Use the state to store the input value
Use onChange event to update the state when the input value changes
Use onSubmit event to handle the form submission
Top Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month