Simpplr
JavaTpoint Interview Questions and Answers
Array Sum Calculation
Calculate the sum of all elements in an array of length N
.
Input:
Line 1: An integer N indicating the size of the array.
Line 2: N integers, the elements of the array, separated by spaces.
Calculate the sum of all elements in an array of length N.
Read the size of the array N and then read N integers as elements of the array.
Iterate through the array and add each element to a running sum.
Return the final sum as the output.
Q2. Remove Duplicates from String Problem Statement
You are provided a string STR
of length N
, consisting solely of lowercase English letters.
Your task is to remove all duplicate occurrences of characters in the s...read more
Remove duplicate occurrences of characters in a given string.
Use a hash set to keep track of characters seen so far.
Iterate through the string and add non-duplicate characters to a new string.
Return the new string without duplicate characters.
Q3. Min cost to buy and sell
The minimum cost to buy and sell a product involves considering the purchase price, selling price, and any associated fees.
Calculate the total cost by adding the purchase price and any fees incurred during the buying process.
Calculate the total revenue by subtracting any fees incurred during the selling process from the selling price.
Subtract the total cost from the total revenue to determine the minimum cost to buy and sell.
Q4. Trapping rainwater problem
Trapping rainwater problem involves calculating the amount of rainwater that can be trapped between buildings.
Calculate the maximum height of water that can be trapped at each index
Calculate the water trapped at each index by subtracting the height of the building at that index from the minimum of the maximum heights on its left and right
Sum up the water trapped at each index to get the total amount of rainwater trapped
Q5. How to plan drive ?
Planning a drive involves determining the destination, route, mode of transportation, and necessary supplies.
Decide on the destination and research the route
Choose the mode of transportation (car, train, plane, etc.)
Check for any necessary permits or visas
Pack necessary supplies such as food, water, and clothing
Plan for rest stops and accommodations if needed
Q6. Debaunce function in react
Interview Process at JavaTpoint
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month