{"id":22057,"date":"2021-09-22T17:11:56","date_gmt":"2021-09-22T11:41:56","guid":{"rendered":"https:\/\/python-programs.com\/?p=22057"},"modified":"2021-11-22T18:36:15","modified_gmt":"2021-11-22T13:06:15","slug":"python-program-to-check-if-a-pair-with-given-product-exists-in-a-matrix","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-check-if-a-pair-with-given-product-exists-in-a-matrix\/","title":{"rendered":"Python Program to Check if a Pair with Given Product Exists in a Matrix"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Count Frequency of k in a Matrix of Size n Where Matrix(i, j) = i+j<\/a><\/p>\n

Given a matrix and the product value k, the task is to check whether the pair with the given product value exists in the given matrix or not.<\/p>\n

What is a matrix:<\/strong><\/p>\n

A matrix is a rectangular sequence of numbers divided into columns and rows. A matrix element or entry is a number that appears in a matrix.<\/p>\n

Example:<\/strong><\/p>\n

\"\"<\/p>\n

Above is the matrix which contains 5 rows and 4 columns and having elements from 1 to 20.<\/p>\n

In this order, the dimensions of a matrix indicate the number of rows and columns.<\/p>\n

Here as there are 5 rows and 4 columns it is called a 5*4 matrix.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Matrix :\u00a0\r\n1 5 4\r\n8 6 1\r\n6 2 4\r\n\r\n<\/pre>\n

Output:<\/strong><\/p>\n

Yes, the pair with the given product value k exists in the given matrix<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Matrix :\u00a0\r\n5 2 1\r\n4 6 3\r\n1 7 1<\/pre>\n

Output:<\/strong><\/p>\n

No, the pair with the given product value k does not exist in the given matrix<\/pre>\n

Program to Check if a Pair with Given Product Exists in a Matrix in Python<\/h2>\n

Below are the ways to check whether the pair with the given product value exists in the given matrix or not.<\/p>\n