Decompress Run-Length Encoded List

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.
I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.
We are given a list nums of integers representing a list compressed with run-length encoding.
Consider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0). For each such pair, there are freq elements with value val concatenated in a sublist. Concatenate all the sublists from left to right to generate the decompressed list.
Return the decompressed list.
LeetCode Problem - 1313
import java.util.ArrayList;
class Solution {
public int[] decompressRLElist(int[] nums) {
ArrayList<Integer> al = new ArrayList<>(); // Initialize an ArrayList to store decompressed elements
// Iterate through the input array by 2 steps
for(int i=0; i<nums.length; i+=2){
// Add nums[i+1] to the ArrayList nums[i] times
for(int j=0; j<nums[i]; j++){
al.add(nums[i+1]);
}
}
// Convert ArrayList to array
int[] result = new int[al.size()];
for(int i=0; i<result.length; i++){
result[i] = al.get(i);
}
return result; // Return the decompressed array
}
}




