15,904,153 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by speed blaze (Top 3 by date)
speed blaze
7-Mar-23 9:02am
View
thanks but i'm not good at debugging but i'll do get on it
speed blaze
7-Mar-23 8:42am
View
hi thanks for your suggestions , i'm not getting paid for this code , i'm learning and improving my skills , sorry if i'm wrong in any way
speed blaze
7-Mar-23 8:40am
View
hi all , i would like thank all for your utmost support , i'm learning and i've tried it myself , here i'm new , i'll share my code here
public class Solution {
static public int minLaneChanges(int[] manholes) {
int laneChanges = 0;
// Loop through each point on the track except the last one
for (int i = 0; i < manholes.length - 1;) {
// If there is a manhole at current point, we need to jump to another lane
if (manholes[i] != 0) {
int currentLane = manholes[i];
boolean jumped = false;
// Jump to middle lane first (if not already in it) and check if we can continue on this lane
if (currentLane != 1 && manholes[i + 1] != currentLane) {
laneChanges++;
i++;
jumped = true;
}
// Check if we can continue on the side lanes without jumping again
if (!jumped) {
if (manholes[i + 1] == 0) {
i++;
} else if (manholes[i + 1] != currentLane && manholes[i + 2] == currentLane) {
i += 2;
laneChanges++;
} else {
i += 2;
laneChanges++;
}
}
} else {
i++;
}
}
return laneChanges;
}
}
// the thing is for only one test case it was giving correct outputs , rest of em it was'nt
i'm not sure which aspect do i need to correct