swap

Objective(s): Practice accessing the first and last elements of an array.

Given an array nums, swap the first and last elements.

Examples: 

 swap({ 0, 1, 2} )    -> [2, 1, 0]
 swap({ 5, 4, 3, 2} ) -> [2, 4, 3, 5]

This practice problem can help remind students of a very common error in programming when swapping the values of two variables! Make sure you pay attention to your error so you do not repeat it!

Type your solution        
Skills Practiced:
3.D
4.A
4.B
Copyright © StudyCS 2024 All rights reserved.