TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Harshil Pandey
1.7k
8
587
Cannot implicity convert int to int[]
Jan 13 2021 7:38 AM
Hey, i am new to this forum(first question here).
So Here my problem is that i have this code and the last return statement it says "cannot implicitly convert int to int[]".
Earlier i did a few tweaks to code but no luck can't find the solution!
Now here's the code
using
System;
public
class
Program
{
public
static
void
Main()
{
Console.WriteLine(FindDuplicates([1,2,2,3]));
}
public
int
[] FindDuplicates(
int
[] nums)
{
var tortoise = nums[0];
var hare = nums[0];
while
(
true
)
{
tortoise = nums[tortoise];
hare = nums[nums[hare]];
if
(tortoise == hare)
break
;
}
var ptr1 = nums[0];
var ptr2 = nums[tortoise];
while
(ptr1 != ptr2)
{
ptr1 = nums[ptr1];
ptr2 = nums[ptr2];
}
return
ptr1;
}
}
Reply
Answers (
3
)
Google.GoogleApiException: unable to parse range in C#
How to nest lists in list?