Skip to main content

Array - Enti ra idhi!

What is an Array?

In computer science, an array data structure, or simply an array, is a data structure consisting of a collection of elements (values or variables), each identified by at least one array index or key. An array is stored such that the position of each element can be computed from its index tuple by a mathematical formula.[1][2][3] The simplest type of data structure is a linear array, also called a one-dimensional array.

Programming Questions on Arrays

1)Given an array find the sum of array.
       Input array is {1,2,3,4,5,-4} output: 11

2)Find the missing number in a given array.
       Input array is {7,3,4,5,2} output: 6

3)Find the first missing positive number in a given array.
       Test case 1: input{-1,-2,0,1,2,4} output: 3
       Test case 2: input{-1,-2,0,1,2,3} output: 4

4)Find the maximum and minimum element in a given array.
    Input {99,0,101,-2,2,47,57,35,10} output: min = -2  max = 101

5)Find the Equilibrium index of an array.
    Equilibrium index of an array is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes.
    Ex: arr={-7, 1, 5, 2, -4, 3, 0} output:  3 
    3 is an equilibrium index, because: A[0] + A[1] + A[2] = A[4] + A[5] + A[6]

6)Find the nth largest element in a given array.
   Input array = {10,4,5,2,11,99,57} and n=2    output: 57

7)Find the maximum time from a given array.
  Input array = {1,2,3,4} output: 2341 because maximum time is 23:59

8)Given an array of strings that contains a-z return which is having maximum weight if two or more strings having the same weights return any longest array among them.
   weights are a=1,b=2,c=3,..........z=26
   Test case 1: input {"abc","xyz","ghij"} output: "xyz"

9)Given an array check weather, a given array is a palindrome or not.
Test case 1:   input array = {10,15,25,15,10}    output : Palindrome
Test case 2:   input array = {30,40,50,0,40,30} output : Not a Palindrome

10)Sort the given Array
Given an array that contains both even and odd numbers in it.
Sort even numbers in increasing order and odd numbers in decending order.
 Ex:- input: {6,3,1,5,4,7,8,2}
        output:{2,7,5,3,4,1,6,8}

 Explanation :
 In an given array, even numbers are 6,4,2,8 sorted in there positions -> 2,4,6,8
 Odd number are 3,1,5,7 sorted in there positions -> 7,5,3,1 final array will be {2,7,5,3,4,1,6,8}

11)Given an array find the frequency of a number K
     input: arr = {1,3,5,1,2,5,7,12,5,50} and K = 5
     output: 3 


Cheers keep coding.

Comments

Popular Posts

NCET CodingClub Programming Questions

Programming Questions asked for NCET CodingClub Monsters Hunt CodingClub Facebook Page:  Click Here 1)Find the nth number in the series Series: 1 5 13 25 41 61 85 113 Simple Input and Output Input: 5 Output: 41 2)Monsters hate zeros help them in finding the correct digits.Prove that "a+b+c=d" where a,b,c, and d are Integers. Condition: Remove all the zeros if present in a,b,c, and d Simple Input and Output: Test Case 1: Input : 101 102 103 306 Output: Valid Test Case 2: Input : 1010 1002 0103 2115 Output: Invalid 3)Print the Pattern For solutions  Click Here Cheers keep coding. 

Programming Questions

Lets, Get Started with programming Starting with basic programming questions Check given number is prime or not (Ex: input=3, output = Prime Number) Print prime number between a range Check given number or string is palindrome or not  Find the sum of all elements in a given array Find the sum of all elements which are in odd positions(index) in a given array Print alphabets from A-Z or a-z using while or for loop

Are you String Lover?

Most asked on strings in coding interviews. A string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. 1)Check the given string is a palindrome or not Ex:- input: pop        output:true 2)Check the given two strings is an Anagram or not An  anagram  of a  string  is another  string  that contains the same characters, only the order of characters can be different. For example, “abcd” and “dabc” are an  anagram  of each other. 3)Check the given string is balanced or not Input String will contain "a-z", "( )","[ ]" and "{ }" .The brackets must close in the correct order. Ex: input: abc(){[]}      output: valid         input: (zyx)[{)}]    output: invalid 4)Print the most repeated character in a given string Ex: input: Apple       output: p        input: Google     output: o 5)Print the occurrence of each character in a given string Ex:input: Apple        output: A-1,p-2

Numbers

Programming Questions on Numbers 1) Given a number find the sum of all digits in a number     Input: n = 1234 output: 10     Explanation: 1+2+3+4 = 10 2) Given a number check given number is palindrome or not      Input: n = 12321     output: Palindrome      Input: n = 123         output: not Palindrome 3) Given a number increase each digit by 1 if the digit is 9 make it 0     Input: n = 1798      output: 2809     Explanation:  1 is increased by 1 becomes 2 and the same for the rest of the digits. 4) Given a number find the prime sum     Input: n = 2345       output: 10     Explanation: In the given digits 2,3 and 5 are prime digits so find the sum all prime numbers. 5) Find the biggest of 3 numbers     Input: a=10, b=20, c=15 output: Biggest is 20 6) Find the highest frequency of digit in a given number     Input: n = 1998    output: 9     Explanation: In 1998 , most repeated digit is 9 7) Find a repeated digit in a given number     Input: 2020       output