Final Array State After K Multiplication Operations I

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.
You are given an integer array nums, an integer k, and an integer multiplier.
You need to perform k operations on nums. In each operation:
Find the minimum value
xinnums. If there are multiple occurrences of the minimum value, select the one that appears first.Replace the selected minimum value
xwithx * multiplier.
Return an integer array denoting the final state of nums after performing all k operations.
LeetCode Problem - 3264
class Solution {
public int[] getFinalState(int[] nums, int k, int multiplier) {
// Perform the operation k times
for (int i = 0; i < k; i++) {
// Find the minimum number and its index in the array
int[] tempArr = minNum(nums);
// Multiply the minimum number by the multiplier and update the array
nums[tempArr[1]] = tempArr[0] * multiplier;
}
// Return the final state of the array
return nums;
}
// Helper method to find the minimum number in the array and its index
public int[] minNum(int[] arr) {
int min = Integer.MAX_VALUE; // Initialize the minimum value to the largest possible integer
int idx = -1; // Initialize the index to -1 (invalid index)
// Iterate through the array to find the minimum value and its index
for (int i = 0; i < arr.length; i++) {
if (arr[i] < min) {
min = arr[i];
idx = i;
}
}
// Store the minimum value and its index in the result array
int[] ans = new int[2];
ans[0] = min;
ans[1] = idx;
// Return the result array containing the minimum value and its index
return ans;
}
}




