Posts

Showing posts from October, 2021

DSA Questions As Per Interview Prep SE

Let's see some of the Important Basic to Advanced Questions Regarding Data Structure & Algorithm Array Questions 1. Given a square matrix (2D array), calculate the sum of the primary diagonal and the secondary diagonal.      [[1, 2, 3], [4, 5, 6], [9, 8, 9]]     Primary Diagonal: 1 + 5 + 9 = 15 Secondary Diagonal: 3 + 5 + 7 = 15 2. Find out the duplicate elements from array.      const numArr = [1, 2, 1, 3, 2, 1, 2, 3, 4, 5]     const strArr = "data structure and algorithm discussion" 3.  The Fibonacci series is a sequence of numbers where each number is the sum of the two preceding ones, starting from 0 and 1. Write the program for it      Example: 0,1,1,2,3,5,8,13,21,34,55,…     Time complexity should be O(n)      Formula: F(n)=F(n−1)+F(n−2) 4. Flatten the below given array without using array.flat() method.      [1, [2, 3], [4, 5, 6, [7, 8]]]     Output sho...