Upcoming technologies, programming, problem solving, coding, technology, mobile phones
About us
Get link
Facebook
X
Pinterest
Email
Other Apps
In this blog you will be able to learn python-programming language and problem solving. You can also find solutions for hackerrank problems, google coding problems.
1.DIAGONAL DIFFERENCE Given a square matrix calculate the absolute difference between the sum of it's diagonals. For example, 1 2 3 4 5 6 9 8 9 The left to right diagonal, 1+5+9=15 The right to left diagonal, 3+5+9=17 The absolute difference=|15-17|=2 Input format: The first line of input contain the order of the square matrix(n). The second line contain the matrix(A) of order (n). Output format: Absolute difference of matrix A Sample input: 3 5 8 9 2 5 7 1 4 6 Sample output: 1 Code: Diagonal difference - Code Input: Output: 2.APPLE AND ORANGE Sam's house has an apple tree and an orange tree.In the diagram below, the red line indicates Sam's house which is between the points 's' and 't'.The orange tree is located at point 'a' towards the left of the house and orange tree is located at the point 'b' towards the right of the house. When a fruit falls from the tree it lands 'd' units of distance from the tree on x-axis. Ne...
Solution for hackerRank problem Arrays-DS in Python Problem : An array is a type of data structure that stores elements of the same type in a contiguous block of memory. In an array, A , of size N, each memory location has some unique index, i(where 0 <= i < N), that can be referenced as A[i] or Ai. Reverse an array of integers. Note: If you've already solved our C++ domain's Arrays Introduction challenge, you may want to skip this. Example A = [1, 2, 3] Return [3, 2, 1]. Function Description Complete the function reverseArray in the editor below. reverseArray has the following parameter(s): int A[n]: the array to reverse Returns int[n]: the reversed array Input Format The first line contains an integer, N, the number of integers in A. The second line contains N space-separated integers that make up A. Constraints 1 <= N <= 10^3 1 <= A[i] <= 10^4, where A[i] is the ith integer in A Sample Input 1 Sample Output 1 2 3 4 1 Code : #!/bin/python3 import math impor...
Solution for hackerRank problems What's your name, Tuple in Python. 1. What's your name You are given the first name and lastname of a person on two different lines. Your task is to read them and print the following: "Hello firstname lastname! You just delved into python." Function Description Complete the print_full_name function in the editor below. print_full_name has the following parameters: string first: the first name string last: the last name Prints string: 'Hello firstname lastname! You just delved into python' where firstname and lastname are replaced with first and last. Input Format The first line contains the first name, and the second line contains the last name. Constraints The length of the first and last names are each ≤ . Sample Input 0 Ross Taylor Sample Output 0 Hello Ross Taylor! You just delved into python. Explanation 0 The input read by the program is stored as a string data type. A string is a collection of c...
Comments
Post a Comment