using two new list, why time limit exceeded? java

  • 0

    public class Solution {
    public List<Integer> findDuplicates(int[] nums) {
    List<Integer> list = new ArrayList<Integer>();
    List<Integer> newList = new ArrayList<Integer>();
    for(int m:nums){
    if(!list.contains(m)) list.add(m);
    else newList.add(m);
    return newList;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.