Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gokul.demo.InProgress;
- import java.util.Arrays;
- public class EquationSort {
- public static void main(String[] args) {
- int[] nums = { 1, 2, 3 };
- int[] nums2 = { 1,1,1 };
- sortedSquares(nums, nums2);
- }
- public static int[] sortedSquares(int[] nums, int[] nums2) {
- int i = 0;
- for (; i < nums.length ; i++) {
- nums[i] = (nums2[0] * nums[i] * nums[i]) + (nums2[1] * nums[i]) + nums2[2];
- System.out.println(nums[i]);
- }
- for (int p = 1; p < nums.length; p++) {
- int key = nums[p];
- int j = p - 1;
- while (j >= 0 && nums[j] > key) {
- nums[j + 1] = nums[j];
- j--;
- }
- nums[j + 1] = key;
- }
- System.out.println(Arrays.toString(nums));
- return nums;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement