Skip to content

Instantly share code, notes, and snippets.

View tungla's full-sized avatar

Vũ Hoàng Minh Tùng tungla

  • Ho Chi Minh
View GitHub Profile
// Use HashMap
class Solution {
public int[] relativeSortArray(int[] arr1, int[] arr2) {
int outputArrIndex = 0;
int[] tempArr = Arrays.copyOf(arr2, arr2.length);
Arrays.sort(arr1);
Arrays.sort(tempArr);
int[] outputArr = new int[arr1.length];
HashMap<Integer, Integer> appearHashMap = new HashMap<Integer, Integer>();
LinkedList<Integer> notAppearList = new LinkedList<Integer>();
// TC passed but TLE
// Need optimization
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <iomanip>
using namespace std;
package Sbank;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;