287、寻找重复数 | Hot100 【技巧】 第100题 class Solution { /** *快慢指针是一种在链表或类似结构中常用的技巧,用来检测环的存在以及找到环的起点。在这个问题中,虽然我们处理的是一个数组,但我们可以将数组元素视为指向下一个元素的“指针”,从而模拟出一种链表的结构。 */ public int findDuplicate(int[] nums) { //快慢指针 int slow=0,fast=0; do{ slow = nums[slow]; fast = nums[nums[fast]]; }while(slow != fast); slow = 0; while(slow!=fast){ slow = nums[slow]; fast = nums[fast]; } return slow; } } 31、下一个排列 | Hot100 【技巧】 第99题 class Solution { public void nextPermutation(int[] nums) { int i = nums.length-2;...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with int
Contact int, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack