Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to reverse the rows of a data frame.

Medium

Problem Statement

Write a function to reverse the rows of a data frame.

Sample Input

Data Frame: 
 Name Age
1 John 25
2 Alice 30
3 Bob 22

Sample Output

   Name Age
3   Bob  22
2 Alice  30
1  John  25

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure reverse_rows <- function(df) { # Your logic here } reversed_data <- reverse_rows(data) print(reversed_data)
Log in or sign up to run or submit your code.Log inSign up
Input
Data Frame: 
 Name Age
1 John 25
2 Alice 30
3 Bob 22
Expected Output
   Name Age
3   Bob  22
2 Alice  30
1  John  25