Questions: 1 978

Answers by our Experts: 1 850

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

There are two types of fishes in a pond, A and B.there are N fishes of type A numbered from 1 to N and M.the following two methods are adopted by the fishes of type A to satisfy their hunger.

1)E1:Fish of typeA(n1) eats the fish of type B(n2).

2)E2:Fish of type A(n1) eats the fish of type A(n2) if size(n1)>size(n2).

In the above mentioned context,E1and E2 denote the respective methods and n1 and n2 are the fishes belonging to these types and Size(X) denotes the total number of fish within X.

Example:if size(L)=3 and size(K)=2 and L eats K then the resulting size(L) will be5.

It is feeding time now and the fishes are hungry.theyeat as per the given method and satiate their hunger.your task is to find and return an array defining whether which type A fishes do All type B fishes fall under.

Note: the size of all fishes initially is the same i.e,1

In case the fish is is still Alive,then the ith element should be -1.

Ex1:

i/p1:2

i/p2:3

i/p3:4

i/p4:{{1,1,1},{1,1,2},{1,2,3},{2,1,2}}

o/p:{1,1,1}


The principal of a school wants to speak with some of the students to assess their over all development including studies,most of the teachers were selecting the toppers of their classes but Mr,sam thought of an idea to select the bunch of students who did not have much difference in their marks so that he gains the reputation of a teacher who teaches well to the whole class and not just to a bunch of brilliant students.

Your are required to help mr,sam in selecting K students that can speak with principle from his class .you need to return an integer array representing the marks of the selected students sorted in ascending order.

I/p1:An integer value denoting the number of students in Mr.sam’s class.

I/p2:An integer array of size input1representing the marks of each student

I/p3:An integer K denoting the number of representatives to be

O/p:return an integer array containing the marks of K selected students sorted in ascending order.

Ex:

I/p1:10

I/p2:{950,477,55,602,881,302,859,438,551,382}

I/p3:1

O/pt:{950}


Harrypotter is visiting his uncle’s house ,the house of Black ,and ants to know more about the family through their ancestral tree.He notices that the ancestraltreebegins with the head of the family at the top,having 2 children as his descendants,This pattern is followed throught and each member is represented by unique integer.

Given relationships in the form ofan integer arraywhere the head of the family is at the first position (i=0) and his children areat position (2*i+1) and (2*i+2).

Your task is to help harry find and return all the siblings of any given family member and return them in the form of a sorted array.

Note:if there are no siblings ,return {-1}.

Example:

Input1:5

Input2:{1,2,3,4,5}

Input3:1

Output:{-1}


you want to buy a particular stock at its lowest price and sell it later at its highest price,since the stock market is unpredictable,you steal the price plans of a company for this stock for the next N days.

Find the best price you can get to buy this stock to achieve maximum profit.

Note:The initial price of the stock is 0.

Input1:Nnumber of days.

Input2:Array representing changing stock price for the day.

Output: Your function must return the best price to buy the stock at.

Example:

Input1:5

Input2:{-39957,-17136,35466,21820,-26711}

Output:-57093


John is going through his family photo album.There is a total of N people in the family labeled 0 to N-1.

Find out the number of members of his family who have more than or equal to X children.

Input specification:

Input1:N,denoting the total number of family members.

Input2:X,denoting the minimum number of children a family members should have in order to be included in john’s final set.

Input3:An array of N elements where the ith element denotes the parent of the ith index. If the value of the element is -1,then that family member has no parent.

Example:

Input1:1

Input2:0

Input3:{-1}

Output=1 


In planting field, there are trees in a single row fromleft to right.each tree has avalue V.youcut trees fromleft to right and for each tree ofvalue Vthat you cut,youplant(V+1)% M trees on the right most end with values ranging from 0 to ((V+1)%M)-1.

Initially,there was only one tree with value 2.Find the total number of trees present after cutting K trees.

Example:

Input1:1

Input2:2

Output1:1 


Rob is fond of collecting coins but unfortunately,sometimes he has to sell a coin to get other coins.he puts all his coins one over the other in a column.

(0,i):Add coin with value i to the collection.

(1,0):sell a coin.

Selling a coin:For selling a coin ,he picks up the top coin in the coloumn if he constraint A is satisfied.Constraint A:Rob can only sell the coin if the coin collection value is more than Y.

Upon removal ,the coin collection value goes to the previous value.Initially,with 0 coins ,coin collection value is 0.

Adding a Coin:on adding a coin of value i to the collection the coin collection value increments via the following prodcedure.

If the coin collection had>=X value then current total value is X+i else X+2*i.

Rob needs to find and return the final value of coin collection after Q operations.

Note:Initially,the value X is 0 and not X.

Ex1:

i/p1:10(deciding increment)

i/p2:0(selling coins)

i/p3:1(no of operations)

i/p4:{{0,5}}

o/p:10




Sam is a greedy businessman who has opened N stores in a city.at various locations.

The locations of stores are stored in 1 2-Dimensional array.the coordinates of ith store are defined as follows:

starting point would be input[0][i] and ending location would be input[1][i].

for example:when i=0,input[0][0]=2 and input [1][0]=5,it means that the 0th store spans from 2 uniits to 5 units.

The greedy businessman wants to set up warehouse =s which can supply goods to these stores.

A warehouse can only be set up at a good location.A location is said to be good location if it is lying in the ranfe of [a,b],where a denotes the starting unit of a store and b denotes the end unit of any store S(a,b).

for example: a location ‘X’ is a good location with respect to the store (a,b) ifa<==X<=b.

Note:there can be more than one stores located at a particular.

Ex1:

i/p1:2

i/p2:{{1,2},{3,5}}

o/p:1

Ex2:

i/p1:3

i/p2:{{2,5,9},{3,7,10}}

o/p:3


There are two types of fishes in a pond, A and B.there are N fishes of type A numbered from 1 to N and M.the following two methods are adopted by the fishes of type A to satisfy their hunger.

1)E1:Fish of typeA(n1) eats the fish of type B(n2).

2)E2:Fish of type A(n1) eats the fish of type A(n2) if size(n1)>size(n2).

In the above mentioned context,E1and E2 denote the respective methods and n1 and n2 are the fishes belonging to these types and Size(X) denotes the total number of fish within X.

Example:if size(L)=3 and size(K)=2 and L eats K then the resulting size(L) will be5.

It is feeding time now and the fishes are hungry.theyeat as per the given method and satiate their hunger.your task is to find and return an array defining whether which type A fishes do All type B fishes fall under.

Note: the size of all fishes initially is the same i.e,1.

Ex1:

i/p1:2

i/p2:3

i/p3:4

i/p4:{{1,1,1},{1,1,2},{1,2,3},{2,1,2}}

o/p:{1,1,1}

ex2:

i/p1:1

i/p2:1

i/p3:1

i/p4:{{1,1,1}}

o/p:{1}


Assume that a grocery shop is introducing shopping through mobile. The shop keeper will gets the list of items from the customer through whatsApp. After receiving the list he will prepare the bill for the customer based on the availability of the items. That is, the shopkeeper will check whether the item is available or not by checking the stock in the shop, if the item is available he will add that item to the bill otherwise he will add that item to another list called not-available list. Finally the shopkeeper will send the bill and the not available list to the customer for confirmation. Write a python code to simulate mobile shopping for a grocery shop to generate bill and not available list. Hint : Create the stock list that contains item, unit price and available quantity.

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS