Questions: 5 831

Answers by our Experts: 5 728

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

instead of printing 1x - 1 we need x - 1 how ?


(SIR/MADAM please answer to this question because i'm not getting the desire output)

Nth number sum:

given a list of M numbers and a positive integer N, print the sum of numbers whose position in the list is divisible by N .consider that the position of numbers range from 1 to N

INPUT:

the first line contains two space-separated integers N, M

the second line contain M space-separated integers.

output:

print a single integer representing the required sum

explanation:

Sample Output1

Given N=1 , M=7

and the number list = [4,8,6,6,7,9,3]

As every position is divisible by 1,

4+8+6+6+7+9+3=43

so the output should be 43

sample Output2

Given N=4 , M=13

and the number list = [7,3,10,4,5,8,4,9,6,9,10,1,4]

the position 4 , 8 and 12 divisible by N,

the output should be 4+9+1=14

so the output should be 14


Given a string, write a code to count all palindrome sub string in a given string. Length of palindrome sub string is greater than or equal to 2.

Make a Number system convert to convert a number of any number system to another number system. Implement only Binary, Base 5, Octal, Decimal, and Hexa number systems. Converter should be developed in Python language.

Minimize the cost of an array where


cost = summation of square of difference of two consecutive array elements.


ex:


arr = [1,2,3,4]


sum = (1-2)^2 + (2-3)^2 + (3-4)^2


Output = 3


if I insert any element in the range of (1 to 10^5) between any two items of the array then it will give some other value, like this I have to give the minimum cost possible by inserting a number.



given n and read the next n lines as integers and convert n integers as array. calculate the sum of its prefixes at each index and return the number of positive sum of prefixes.



For Example :


n = 4, next n lines 1, 3, 0, -5


read inputs as array = [-9,3,0,1,-1]


converts into _____ format Like


[3, 1, 0, -9, -1]


Then calculate sum of prefixes like


[3, 4, 4, -5,-6]


Now count the positive numbers above the list is 3.


so output is 3





Find the unique alphabet in a string and find the index of that character If multiple unique chars are in a given string, then return the first unique character index,if there is no unique alphabet then print -1


Note: index format is 1



For example :


given string: statistics


Given string having a, c as unique chars


The first unique char is a


character an index in the given string is 3 (index is 1 format)


output: 3


For example : "helloram"


unique chars = [h,e,o,r,a,m]


first one out of them is "h



Minimize the cost of an array where


cost = summation of square of difference of two consecutive array elements.


ex:


arr = [1,2,3,4]


sum = (1-2)^2 + (2-3)^2 + (3-4)^2


Output = 3



Given a string, write a code to count all palindrome sub string in a given string. Length of palindrome sub string is greater than or equal to 2.





Ravan's dream is to win Tic-Tac-Toe championship.to accomplish this he practices alone at home to learn the strategies of the game . your task is to identify the cell where Ravan should place his third piece so that he wins the game. Assume that each cell in the tic-tac-toe board is marked with a number as shown in the below

tic tac toe

0 1 2

3 4 5

6 7 8

input:

The first line of input contain two space-seperated integers representing the cells where Ravan has placed his first two pieces

output:

output should be a single line integer representing the cell where ravan should place his final piece

explanation

sample Output 1 :

ravan's first two moves are 0 and 1 so he not 2 to win the game .because it will complete the first row so the out put is 2

sample Output 2 :

ravan's first two moves are 0 and 3 so he not 6 to win the game .because it will complete the first row so the out put is 6


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS