All Problems

Problem title

Difficulty

Avg time to solve

Permutations of a String

Moderate

15 mins

Minimum Coins

Moderate

30 mins

Roman Numeral To Integer

Easy

15 mins

Match Specific Pattern

Easy

15 mins

Sum Of LCM

Moderate

15 mins

Diameter Of Binary Tree

Easy

10 mins

Move Last Element

Easy

15 mins

Next Greater Element

Easy

10 mins

K-th Largest Sum Subarray

Easy

10 mins

Left Sum

Easy

10 mins

Problem

Submissions

11

Difficulty: EASY

Avg. time to solve

15 min

Success Rate

90%

Problem Statement

```
The first line of input contains an integer ‘T’, denoting the number of test cases. Then each test case follows.
The first line of each test case contains the Integer ‘N’ denoting the number of elements in the linked list. The first element is the head of the given linked list.
The second and the last line of each test case contains ‘N’ space-separated integers representing the node value of the linked list.
```

```
For each test case, print a single line containing ‘N’ single space-separated integers, the elements of the new linked list.
The output of each test case will be printed on a separate line.
```

```
You do not need to print anything, it has already been taken care of. Just implement the given function.
```

```
1 <= T <= 5
1 <= N <= 5 * 10 ^ 3
-10 ^ 9 <= nodeVal[i] <= 10 ^ 9
Time Limit: 1 sec.
```

```
2
5
5 4 3 2 1
1
5
```

```
1 5 4 3 2
5
```

```
In the first test case, after moving the last element ‘1’ to first. The new linked list is 1 -> 5 -> 4 -> 3 -> 2 -> NULL.
In the second test case, it contains only one element, so the first element is the last element.
```

```
1
4
-1 0 0 -1
```

```
-1 -1 0 0
```

```
In the first test case, after moving the last element ‘-1’ to first. The new linked list is -1 -> -1 ->0 -> 0 -> NULL.
```

Java (SE 1.8)

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Theme

Solution submission not allowed

Save Code

Reset Code