enotes the number of test cases. The first line of each test case or query contains the elements o e singly linked list separated by a single space. The second line contains the integer value 'N'. It enotes the data to be searched in the given singly linked list. Remember/Consider :While specifying e list elements for input, -1 indicates the end of the singly linked list and hence -1 would never be a st element. Output format :For each test case, return the index/position of 'N' in the singly linked st. Return -1, otherwise. Output for every test case will be printed in a separate line. Note: You do ot need to print anything; it has already been taken care of. Just implement the given function. onstraints :1 <= T <= 10^20 <= M <= 10^5 Where 'M' is the size of the singly linked list. Time Limit: 1 ecSample Input 1:23 452619-1510 20 30 40 50 60 70-16Sample Output 1 :2-1 Explanation for ample Output 1:In test case 1, 'N' = 5 appears at position 2 (0-based indexing) in the given linked st. In test case 2, we can see that 'N' = 6 is not present in the given linked list.Sample Input 2:21 23 452619-16Sample Output 2:-14 Explanation for Sample Output 2:In test case 1, we can see at 'N' = 2 is not present in the given linked list. In test case 2, 'N' = 6 appears at position 4 (0-based dexing) in the given linked st.Solutions:////// *********
enotes the number of test cases. The first line of each test case or query contains the elements o e singly linked list separated by a single space. The second line contains the integer value 'N'. It enotes the data to be searched in the given singly linked list. Remember/Consider :While specifying e list elements for input, -1 indicates the end of the singly linked list and hence -1 would never be a st element. Output format :For each test case, return the index/position of 'N' in the singly linked st. Return -1, otherwise. Output for every test case will be printed in a separate line. Note: You do ot need to print anything; it has already been taken care of. Just implement the given function. onstraints :1 <= T <= 10^20 <= M <= 10^5 Where 'M' is the size of the singly linked list. Time Limit: 1 ecSample Input 1:23 452619-1510 20 30 40 50 60 70-16Sample Output 1 :2-1 Explanation for ample Output 1:In test case 1, 'N' = 5 appears at position 2 (0-based indexing) in the given linked st. In test case 2, we can see that 'N' = 6 is not present in the given linked list.Sample Input 2:21 23 452619-16Sample Output 2:-14 Explanation for Sample Output 2:In test case 1, we can see at 'N' = 2 is not present in the given linked list. In test case 2, 'N' = 6 appears at position 4 (0-based dexing) in the given linked st.Solutions:////// *********
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 8PE
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 2 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
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr