Tip 1: Practice at least 250 questions.
Tip 2: Do at least 2 projects.
Tip 3: Focus on both DSA and development.
Tip 1: Add a good project.
Tip 2: Write only the things you are confident about.



The idea is to use a recursive approach to calculate the sum of an array by breaking it down into two cases:
Base case – If the array is empty, the sum is 0.
Recursive case – The sum is calculated by adding the first element to the sum of the remaining elements, which is computed through a recursive call with the array shifted by one position and the size reduced by one.



For 'arr' = [ 1, 2, 3, 1, 2]. you need to return 1.
Using a hash table, this approach stores each element’s frequency and then finds the element with the maximum frequency. This method is efficient in terms of both time and space.



The idea is to use Kadane’s algorithm, which traverses the array from left to right and, for each element, finds the maximum sum among all subarrays ending at that element. The result is the maximum of all these values.
To calculate the maximum sum of a subarray ending at the current element (let’s call it maxEnding), we use the maximum sum ending at the previous element. For any element, we have two choices:
Extend the maximum sum subarray ending at the previous element by adding the current element to it. If the maximum subarray sum ending at the previous index is positive, it is always better to extend the subarray.
Start a new subarray from the current element if the maximum subarray sum ending at the previous index is negative. In this case, starting a new subarray from the current element is a better choice.
This means that maxEnding at index i is calculated as:
maxEnding[i]=max(maxEnding[i−1]+arr[i],arr[i])
The maximum value of maxEnding at any index will be our final answer.



153 = 1^3 + 5^3 + 3^3.
Therefore 153 is an Armstrong number.
Create a recursive function armstrongSum(). In this function:
Calculate the value of the last digit raised to the power of the total number of digits, K.
Add it to the sum of the remaining digits raised to the power of K by making a recursive call. This call processes the next digit by removing the current last digit from the number.
Continue this process until N becomes 0, indicating that all digits have been processed. At this point, the function returns 0.
Finally, compare the sum returned by the armstrongSum() function with the original number.
If the sum equals the original number, return true.
Otherwise, return false.
Basic HR questions were asked.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
To make an AI less repetitive in a long paragraph, you should increase: