[LeetCode]--349. Intersection of Two Arrays

这篇博客介绍了如何使用函数解决LeetCode上的349题,即找出两个给定数组的交集。示例中,给定nums1 = [1, 2, 2, 1]和nums2 = [2, 2],交集为[2]。题目要求结果中的元素必须是唯一的,并且可以无序排列。" 125000426,13656558,Spring Boot逆向工程快速指南,"['spring boot', 'java', '数据库逆向工程', 'mybatis逆向工程', '代码生成']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Given two arrays, write a function to compute their intersection.

Example:
Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].

Note:
Each element in the result must be unique.
The result can be in any order.

给定两个数组,求数组的交集。输出结果中的元素唯一,输出数组可以无序。

public int[] intersection(int[] nums1, int[] nums2) {
        int j = 0;
        int[] temp = new int[nums2.length];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值