Simple solution using ArrayList Java. Self explanatory
class Solution {\n\n    public int lastStoneWeight(int[] stones) {\n        \n        ArrayList ar = new ArrayList<>();\n        \n        for(int i=0;i1){\n   
class Solution {\n\n    public int lastStoneWeight(int[] stones) {\n        \n        ArrayList<Integer> ar = new ArrayList<>();\n        \n        for(int i=0;i<stones.length;i++){\n            ar.add(stones[i]);\n        }\n        \n       \n       \n        while(ar.size()>1){\n             \n        Collections.sort(ar);\n            \n            int y = ar.get(ar.size()-1);\n            ar.remove(new Integer(y));\n            \n            int x = ar.get(ar.size()-1);\n            ar.remove(new Integer(x));\n            \n            if(x!=y){\n                ar.add(y-x);\n            }\n           \n            \n        }\n        \n        if(ar.isEmpty()){\n            return 0;\n        }else{\n            return ar.get(0);\n        }\n        \n    }\n}
['Array', 'Java']