Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if
来源:互联网 发布:淘宝电脑版官方下载 编辑:程序博客网 时间:2024/05/21 09:38
Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list).
import java.util.ArrayList;
import java.util.List;
public class Duplicate {
public static void main(String args[]) {
List<Integer> list1 = new ArrayList<Integer>();
List<Integer> list2 = new ArrayList<Integer>();
for (int i = 0; i < 5; i++)
list1.add((int) (Math.random() * 10));
for (int i = 0; i < 10; i++)
list2.add((int) (Math.random() * 10));
for (int i = 0; i < list1.size(); i++) {
System.out.print(list1.get(i) + " ");
}
System.out.println();
for (int j = 0; j < list2.size(); j++) {
System.out.print(list2.get(j) + " ");
}
System.out.println();
for (int i = 0; i < list2.size(); i++) {
for (int j = 0; j < list1.size(); j++) {
if (list1.get(j) == list2.get(i)) {
System.out.print(list2.get(i) + " ");
}
}
}
}
}
- Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if
- [LeetCode]Merge Interval (given list of interval, merge whatever you can merge)
- How do you find length of a Singly Linked list
- CareerCup Find all the conflicting appointments from a given list of n appointments.
- P14 (*) -P15 (**)Duplicate the elements of a list,Duplicate the elements of a list a given number of
- LeetCode141:Given a linked list, determine if it has a cycle in it.
- How can I find which tables reference a given table
- P15 (**) Replicate the elements of a list a given number of times.
- P23 (**) Extract a given number of randomly selected elements from a list.
- given two unordered list find the greatest common integer
- P17 (*) Split a list into two parts; the length of the first part is given.
- Given a linked list, swap values inside nodes.
- How do you remove the duplicate characters in a given string without using any additional buffer.
- [CrackCode] 4.4 Creates a linked list of all the nodes at each depth of a given tree
- Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
- LeetCode Given a linked list, return the node where the cycle begins. If there is no cycle, returnn
- Given a tree, find the node with the minimum sum of distances to other nodes
- 4 4 Given a binary search tree, design an algorithm which creates a linked list of all the nodes at
- MYSQL5.5字符集修改的变化
- 我的助理辞职了
- objective-c 编程总结(第九篇)运行时操作 - 序列化
- oracle解锁
- There Is No ‘I’ in Architecture written by Dave Quick
- Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if
- objective-c 编程总结(第八篇)运行时操作 - 消息转发
- web 锁屏登录
- linux下mysql的使用方法
- Xcode/Git Repository Error: “Please verify that the working copy is reachable and try again.”
- Spring AOP(一)
- mysql5.5 master-slave(Replication)配置
- RCP:为工具栏(CoolBar)贡献右键菜单
- Windows Phone 游戏 Roll In The Hole 去除 XBL 服务