Reverse the array problem:

You are given an array of integers arr[]. You have to reverse the given array. Note: Modify the array in place. Examples: Input: arr = [1, 4, 3, 2, 6, 5] Output: [5, 6, 2, 3, 4, 1]Explanation: The elements of the array are [1, 4, 3, 2, 6, 5]. After reversing the array, the first element goes to … Read more

Leetcode problem no. :1513.

1513. Number of Substrings With Only 1s GENERAL APPROACH We scan the string once from left to right.We count how many consecutive ‘1’ characters appear in a row. => (k⋅(k+1))/2 Then reset the counter. At the end, we add the contribution of the last streak. This approach is optimal with O(n) time and O(1) space. … Read more