260. Single Number III

来源:互联网 发布:win7系统安装软件 编辑:程序博客网 时间:2024/04/20 06:35

解法一:

public class Solution {    public int[] singleNumber(int[] nums) {        int[] copyNum = new int[nums.length];LinkedList<Integer> list = new LinkedList<Integer>();for (int i : nums) {if (list.contains(i)) {list.remove(list.indexOf(i));}else {list.add(i);}}int res[] = new int[2];res[0] = list.pop();res[1] = list.pop();return res;    }}

解法二:


0 0