Nagarro
20+ Shades of Web Interview Questions and Answers
Q1. Digits Decoding Problem Statement
A few days back, Ninja encountered a string containing characters from ‘A’ to ‘Z’ which indicated a secret message. For security purposes, he encoded each character of the stri...read more
The problem involves decoding a numeric sequence into a valid string using a given mapping of characters to numbers.
Use dynamic programming to count the number of ways to decode the sequence.
Consider different cases for decoding single digits and pairs of digits.
Keep track of the number of ways to decode at each position in the sequence.
Return the final count modulo 10^9 + 7 as the answer.
Q2. Secret Message Decoding Problem
Ninja encountered an encoded secret message where each character from 'A' to 'Z' is mapped to a numeric value (A = 1, B = 2, ..., Z = 26). Given a numeric sequence (SEQ) derived ...read more
The problem involves decoding a numeric sequence back into a valid string based on a given mapping of characters to numeric values.
Use dynamic programming to keep track of the number of ways to decode the sequence at each position.
Consider edge cases such as '0' and '00' which do not have valid decodings.
Handle cases where two digits can be combined to form a valid character (e.g., '12' corresponds to 'L').
Q3. Character Counting Challenge
Create a program that counts and prints the total number of specific character types from user input. Specifically, you need to count lowercase English alphabets, numeric digits (0-...read more
Create a program to count lowercase alphabets, digits, and white spaces from user input until '$' is encountered.
Read characters from input stream until '$' is encountered
Count lowercase alphabets, digits, and white spaces separately
Print the counts of each character type as three integers separated by spaces
Q4. Preorder Traversal Problem Statement
You are provided with the root node of a binary tree comprising N
nodes. Your objective is to output its preorder traversal. Preorder traversal of a binary tree is performed...read more
Implement a function to perform preorder traversal on a binary tree given the root node.
Create a recursive function to traverse the tree in preorder fashion.
Visit the root node, then recursively traverse left subtree, followed by right subtree.
Store the visited nodes in an array and return the array as the result.
Example: For the input tree [1, 2, 3, 4, -1, 5, 6, -1, 7, -1, -1, -1, -1, -1, -1], the preorder traversal output should be [1, 2, 4, 7, 3, 5, 6].
Q5. String Transformation Problem
Given a string (STR
) of length N
, you are tasked to create a new string through the following method:
Select the smallest character from the first K
characters of STR
, remove it fr...read more
The task is to transform a given string by selecting the smallest character from the first K characters and appending it to a new string until the original string becomes empty.
Iterate through the string while there are characters remaining
For each iteration, select the smallest character from the first K characters
Remove the selected character from the original string and append it to the new string
Repeat until the original string is empty
Return the final new string
Q6. Make Unique Array Challenge
Your task is to determine the minimum number of elements that need to be removed from an array 'ARR' of size 'N' such that all the remaining elements are distinct. In simpler terms, ...read more
Find the minimum number of elements to remove from an array to make all elements distinct.
Iterate through the array and keep track of the frequency of each element using a hashmap.
Count the number of elements that have a frequency greater than 1, as those need to be removed.
Return the count of elements to be removed.
The CTC offered for this position is competitive and includes salary, benefits, and bonuses.
CTC includes salary, benefits, bonuses, and any other perks offered by the company.
It is important to consider the overall compensation package, not just the base salary.
Negotiation for a higher CTC may be possible based on experience and skills.
Example: CTC for this position ranges from $100,000 to $120,000 per year.
Static variables and classes in OOP are used to store data that is shared among all instances of a class.
Static variables are shared among all instances of a class and retain their value throughout the program's execution.
Static classes cannot be instantiated and are used to group related static members together.
Example: In a class representing a bank account, a static variable could be used to store the total number of accounts created.
Example: A static class in a math libra...read more
I can design a login page for Facebook with user input fields for email/phone and password, a 'Login' button, and 'Forgot password?' link.
Include user input fields for email/phone and password
Add a 'Login' button for submitting credentials
Include a 'Forgot password?' link for password recovery
Design the page with Facebook branding and color scheme
Q10. 4. React: What is Virtual DOM, useState and different types of Hooks in React
Virtual DOM is a lightweight copy of the actual DOM, useState is a hook for managing state in functional components, and Hooks are functions that let you use state and other React features in functional components.
Virtual DOM is a lightweight copy of the actual DOM that React uses to improve performance by updating only the necessary parts of the actual DOM.
useState is a hook in React that allows functional components to have state. It returns an array with the current state ...read more
Q11. 5. SQL: Different Types of triggers, define index and its types
Triggers in SQL are special stored procedures that are automatically executed when certain events occur in a database. Indexes in SQL are used to speed up the retrieval of data from tables.
Types of triggers: DML triggers (insert, update, delete), DDL triggers (create, alter, drop), and Logon triggers.
Indexes in SQL are used to quickly retrieve data from tables. Types of indexes include clustered, non-clustered, unique, and composite indexes.
Example: CREATE TRIGGER trgAfterIns...read more
Q12. create a todo kind app using react, then optimize by adding custom hooks, optimize performance
Create a todo app using React, optimize with custom hooks for performance.
Create a basic todo app using React
Identify areas for optimization such as state management
Implement custom hooks for optimized performance
Use useMemo and useCallback hooks to optimize rendering
Consider lazy loading components for better performance
Q13. What is Node.js event loop and how its work?
Node.js event loop is a mechanism that allows Node.js to perform non-blocking I/O operations asynchronously.
Event loop is responsible for handling asynchronous operations in Node.js.
It allows Node.js to perform multiple operations simultaneously without blocking the execution.
Event loop continuously checks the event queue for new events and executes them in a non-blocking manner.
Callbacks are used to handle the completion of asynchronous operations in Node.js.
Q14. What are functional interfaces in programming?
Functional interfaces in programming are interfaces with only one abstract method, used for lambda expressions.
Functional interfaces have only one abstract method
They can have multiple default or static methods
Used for lambda expressions in Java 8+
Examples include java.lang.Runnable, java.util.Comparator
Q15. 3. JavaScript: difference between var and let keyword, closure function
var keyword has function scope, let keyword has block scope. Closure function is a function defined inside another function.
var keyword has function scope, let keyword has block scope
Variables declared with var are hoisted to the top of their function, let variables are not hoisted
Closure function is a function defined inside another function, has access to the outer function's variables
Q16. what is MVVM and design patterns
MVVM is a design pattern that separates the UI from the business logic, promoting code reusability and maintainability.
MVVM stands for Model-View-ViewModel
Model represents the data and business logic
View is the UI components that the user interacts with
ViewModel acts as a mediator between the Model and View, handling user inputs and updating the Model
Design patterns are reusable solutions to common problems in software design
Examples of design patterns include Singleton, Fact...read more
Q17. 1. Explain Middleware in .Net Core
Middleware in .Net Core is a software component that acts as a bridge between an application's request processing pipeline and the server.
Middleware components are executed in the order they are added to the pipeline.
They can perform tasks like authentication, logging, error handling, etc.
Middleware can be added using the 'UseMiddleware' method in the 'Configure' method of Startup class.
Q18. explain Clean Architecture
Clean Architecture is a software design approach that separates concerns and enforces a clear structure for code organization.
Clear separation of concerns between different layers (e.g. presentation, domain, data)
Dependency Rule: inner layers should not depend on outer layers
Use of interfaces to define boundaries between layers
Focus on testability and maintainability
Examples: Hexagonal Architecture, Onion Architecture
Q19. explain solid principles
SOLID principles are a set of five design principles in object-oriented programming to make software designs more understandable, flexible, and maintainable.
Single Responsibility Principle (SRP) - A class should have only one reason to change.
Open/Closed Principle (OCP) - Software entities should be open for extension but closed for modification.
Liskov Substitution Principle (LSP) - Objects of a superclass should be replaceable with objects of its subclasses without affecting...read more
Q20. create debounce function
Debounce function delays the execution of a function until after a specified amount of time has passed since the last time it was invoked.
Use setTimeout to delay the execution of the function
Use clearTimeout to reset the timer if the function is invoked again within the specified time period
Commonly used in scenarios like search bars to prevent excessive API calls
Q21. Intents in android
Intents in Android are messaging objects used to request an action from another app component.
Intents are used to start activities, services, and broadcast receivers in Android.
There are two types of intents: explicit intents and implicit intents.
Explicit intents specify the component to start by name, while implicit intents specify the action to perform.
Example: Intent intent = new Intent(this, SecondActivity.class); startActivity(intent);
More about working at Nagarro
Top HR Questions asked in Shades of Web
Interview Process at Shades of Web
Top Senior Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month