Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
contributor-omu47
leetcode-everydy
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
leetcode-everydy
Public
Notifications
You must be signed in to change notification settings
Fork
0
(
0
)
Star
0
(
0
)
You must be signed in to star a repository
About
No description, website, or topics provided.
Activity
Stars
0
stars
Watchers
0
watching
Forks
0
forks
Report repository
main
Branches
Tags
Go to file
Code
Open more actions menu
Latest commit
History
21 Commits
21 Commits
Folders and files
Name
Name
Last commit message
Last commit date
1386. Cinema Seat Allocation
1386. Cinema Seat Allocation
1563. Stone Game V
1563. Stone Game V
1872- stone game Vlll
1872- stone game Vlll
1927.sum game
1927.sum game
2029. Stone Game IX
2029. Stone Game IX
2058. Find the Minimum and Maximum Number of Nodes Between Critical Points Problem Description A critical point in a linked list is defined as either a local maxima or a local minima. * A node is a local maxima if its value is strictly greater than the previous and next nodes. * A node is a local minima if its value is strictly smaller than the previous and next nodes. Given a linked list head, return an array [minDistance, maxDistance]. If there are fewer than two critical points, return [-1, -1]. Pattern & Intuition * Pattern: Fixed-Size Sliding Window (Triplet Traversal) + Single-Pass Greedy Tracking. * Triplet Window: Traverse using three nodes (prev, curr, curr.next) to identify whether curr is a peak or valley. * Min Distance: Always occurs between two adjacent critical points. Track the previous critical point index to compute min(min_dist, curr_idx - prev_idx). * Max Distance: Always spans the first and the last critical point (last_idx - first_idx). Implementation (Python 3) # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]: if not head or not head.next or not head.next.next: return [-1, -1] first_cp = -1 prev_cp = -1 min_dist = float('inf') prev = head curr = head.next idx = 1 while curr.next: # Check if current node is a local maxima or minima is_critical = (curr.val > prev.val and curr.val > curr.next.val) or \ (curr.val < prev.val and curr.val < curr.next.val) if is_critical: if first_cp == -1: first_cp = idx else: min_dist = min(min_dist, idx - prev_cp) prev_cp = idx prev = curr curr = curr.next idx += 1 # If fewer than 2 critical points were found if first_cp == -1 or prev_cp == first_cp: return [-1, -1] max_dist = prev_cp - first_cp return [min_dist, max_dist] Complexity Analysis | Metric | Complexity | Description | |---|---|---| | Time Complexity | O(N) | Single traversal over the linked list of N nodes. | | Space Complexity | O(1) | Uses a fixed number of pointer and index variables without extra memory. |
2058. Find the Minimum and Maximum Number of Nodes Between Critical Points Problem Description A critical point in a linked list is defined as either a local maxima or a local minima. * A node is a local maxima if its value is strictly greater than the previous and next nodes. * A node is a local minima if its value is strictly smaller than the previous and next nodes. Given a linked list head, return an array [minDistance, maxDistance]. If there are fewer than two critical points, return [-1, -1]. Pattern & Intuition * Pattern: Fixed-Size Sliding Window (Triplet Traversal) + Single-Pass Greedy Tracking. * Triplet Window: Traverse using three nodes (prev, curr, curr.next) to identify whether curr is a peak or valley. * Min Distance: Always occurs between two adjacent critical points. Track the previous critical point index to compute min(min_dist, curr_idx - prev_idx). * Max Distance: Always spans the first and the last critical point (last_idx - first_idx). Implementation (Python 3) # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def nodesBetweenCriticalPoints(self, head: Optional[ListNode]) -> List[int]: if not head or not head.next or not head.next.next: return [-1, -1] first_cp = -1 prev_cp = -1 min_dist = float('inf') prev = head curr = head.next idx = 1 while curr.next: # Check if current node is a local maxima or minima is_critical = (curr.val > prev.val and curr.val > curr.next.val) or \ (curr.val < prev.val and curr.val < curr.next.val) if is_critical: if first_cp == -1: first_cp = idx else: min_dist = min(min_dist, idx - prev_cp) prev_cp = idx prev = curr curr = curr.next idx += 1 # If fewer than 2 critical points were found if first_cp == -1 or prev_cp == first_cp: return [-1, -1] max_dist = prev_cp - first_cp return [min_dist, max_dist] Complexity Analysis | Metric | Complexity | Description | |---|---|---| | Time Complexity | O(N) | Single traversal over the linked list of N nodes. | | Space Complexity | O(1) | Uses a fixed number of pointer and index variables without extra memory. |
2213. Longest Substring of One Repeating Character
2213. Longest Substring of One Repeating Character
2948.make lexicographically smallest array by swappibg elements
2948.make lexicographically smallest array by swappibg elements
2996. Smallest Missing Integer Greater Than Sequential Prefix Sum
2996. Smallest Missing Integer Greater Than Sequential Prefix Sum
3069. Distribute Elements Into Two Arrays I
3069. Distribute Elements Into Two Arrays I
3090. Maximum Length Substring With Two Occurrences
3090. Maximum Length Substring With Two Occurrences
3568.minimum moves to clean the classroom
3568.minimum moves to clean the classroom
3702. Longest Subsequence With Non-Zero Bitwise XOR
3702. Longest Subsequence With Non-Zero Bitwise XOR
3718.smallest missing multiple of k
3718.smallest missing multiple of k
3876. Construct Uniform Parity Array II
3876. Construct Uniform Parity Array II
LeetCode 2958: Length of Longest Subarray With at Most K Frequency
LeetCode 2958: Length of Longest Subarray With at Most K Frequency
LeetCode 3622: Check Divisibility by Digit Sum and Product
LeetCode 3622: Check Divisibility by Digit Sum and Product
View all files
About
No description, website, or topics provided.
Activity
Stars
0
stars
Watchers
0
watching
Forks
0
forks
Report repository
Releases
Packages
Contributors
You can’t perform that action at this time.