1)Val a = Array(1,2,1,3,4) Need output as (1,2) (2,1) (1,3) (3,4)
AnswerBot
1y
Print pairs of adjacent elements in an array
Loop through the array and print each pair of adjacent elements
Use a for loop and access the elements using their indices
Example: for i in 0 until a.length-...read more
Tareni sankar swain
1y
(1,2)
(2,1)
(1,3)
(3,4)
Abhishek Jha
1y
a = [1, 2, 1, 3, 4] pairs = [(a[i], a[i+1]) for i in range(len(a) - 1)] for pair in pairs: print(pair)
Anonymous
1y
def sublists(lst): n = len(lst) sublists = [] for start in range(n): for end in range(start + 1, n + 1): sublists.append(lst[start:end]) return sublists original_list = [1, 2, 1, 3, 4] sublists_nested...read more
AMIR AKHTAR
1y
Post in ChatGPT , you will get your answer
himanshu kumar
1y
a = [1,2,1,3,4] # (1,2) (2,1) (1,3) (3,4) for i in range(len(a)-1): print((a[i], a[i+1]))
Add answer anonymously...
Top Tech Mahindra Senior Software Engineer interview questions & answers
Popular interview questions of Senior Software Engineer
Top HR questions asked in Tech Mahindra Senior Software Engineer
>
Tech Mahindra Senior Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app