We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
unorthodox java solution but i assume very less space complexity
class Result {
/*
* Complete the 'jimOrders' function below.
*
* The function is expected to return an INTEGER_ARRAY.
* The function accepts 2D_INTEGER_ARRAY orders as parameter.
*/
public static List<Integer> jimOrders(List<List<Integer>> orders) {
// Write your code here
long[] val=new long[orders.size()];
for(int i=0;i<orders.size();i++){
long temp=orders.get(i).get(0)+orders.get(i).get(1);
val[i]=temp*10000 +(i+1);
}
Arrays.sort(val);
System.out.println(Arrays.toString(val));
ArrayList<Integer> list=new ArrayList<>();
for(long i:val){
list.add((int)(i%10000));
}
return list;
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jim and the Orders
You are viewing a single comment's thread. Return to all comments →
unorthodox java solution but i assume very less space complexity
class Result {
}