apurva's Site

apurva appu

DIAGONAL ELEMENTS

Consider a matrix and print principal diagonal and opposite diagonal from the given matrix. Principal Diagonal: Condition is if row number is equal to column number ,then it is principal diagonal. 123451102030405021112131415321222324254313233343554142...

BETWEEN TWO SETS-HACKERRANK

PROBLEM STATEMENT : You will be given two arrays of integers and asked to determine all integers that satisfy the following two conditions:The elements of the first array are all factors of the integer being consideredThe integer being considered is a ...

Sock Merchant -HACKERRANK

Problem statement: John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. Expla...

Birthday Cake Candles -Hackerrank Problem solving

PROBLEM STATEMENT: You are in charge of the cake for your niece's birthday and have decided the cake will have one candle for each year of her total age. When she blows out the candles, she will only be able to blow out the tallest ones. Your task is ...

FIND RUNNER UP SCORE-HACKERRANK

PROBLEM STATEMENT: Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given scores. Store them in a list and find the score of the runner-up. This is a problem from hackerrank pyth...

DISPLAY ONLY EVEN OR ODD POSITIONS IN A ARRAY

This post is about how normal loops we use can be modified to access in differently . DISPLAY ONLY EVEN POSITION CHARACTERS Let consider a question asks to display only even position array elements then approach one uses is pass through each and ever...

Bit wise operator "and" use

Many programs uses bit wise operators to solve many problems. Find given number is Even or Odd: "and" operator is used example: consider a decimal number 'a' if a is 10 it's binary notation is 1010 the least significant bit is 0 if decimal number 1...

Find the minimum and maximum elements from array

Consider an array , we are asked to find the minimum and maximum elements from an array. The explanation is : consider two variables min,max and initialize them with INT_MAX,INT_MIN values while you traverse across the array , if min variable value is ...

Structures in C

C has a user defined datatype and Structure is one of them. Syntax for creating a structure: struct { datatype variable_1; datatype variable_2; }; The points to remember about structure are: 1.A structure is used in data structures for creation of no...

Datatypes in C

DATATYPE: What type of data is given into a variable is called datatype. Different type of datatypes:Primitive datatypeDerived datatypesPRIMITIVE DATATYPE: These are built in very commonly used datatypes they are char ,int,float,void. INTEGER DATATYPE:...