SEARCH IN MATRIX You are give a matrix (a list of lists) of DISTINCT integers and a target number. Each row in the matrix is SORTED and each column in the matrix is SORTED. Our matrix does not necessarily have the same height and width. Write a function that returns a list of the row and column indices of the target integer IF it is contained in the matrix, otherwise return [-1, -1]. EXAMPLE INPUT matrix = [ [1,4,7,12,15,1000], [2,5,19,31,32,1001], [3,8,24, 33, 35, 1002], [40,41,42,44,45,1003], [99,100,103,106,128,1004] ] target=44 EXAMPLE OUTPUT result = = [3,3] Finish the code bellow with given requirements: def search_in_matrix(matrix, target): pass
SEARCH IN MATRIX You are give a matrix (a list of lists) of DISTINCT integers and a target number. Each row in the matrix is SORTED and each column in the matrix is SORTED. Our matrix does not necessarily have the same height and width. Write a function that returns a list of the row and column indices of the target integer IF it is contained in the matrix, otherwise return [-1, -1]. EXAMPLE INPUT matrix = [ [1,4,7,12,15,1000], [2,5,19,31,32,1001], [3,8,24, 33, 35, 1002], [40,41,42,44,45,1003], [99,100,103,106,128,1004] ] target=44 EXAMPLE OUTPUT result = = [3,3] Finish the code bellow with given requirements: def search_in_matrix(matrix, target): pass
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter16: Searching, Sorting And Vector Type
Section: Chapter Questions
Problem 16SA
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning