102. Linked List Cycle【medium】】的更多相关文章

Given a linked list, determine if it has a cycle in it.   Example Given -21->10->4->5, tail connects to node index 1, return true Challenge Follow up:Can you solve it without using extra space? 解法一: class Solution { public: /** * @param head: The…
92. Reverse Linked List II[Medium] Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note:Given m, n satisfy the fo…
141. Linked List Cycle[easy] Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 解法一: /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x…
Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in…
2. Add Two Numbers[medium] You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You…
82. Remove Duplicates from Sorted List II[Medium] Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 1->2->3->3->4->4->5, return 1->2->5…
203. Remove Linked List Elements[easy] Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5 Credits:Special than…
61. Search for a Range[medium] Given a sorted array of n integers, find the starting and ending position of a given target value. If the target is not found in the array, return [-1, -1]. Have you met this question in a real interview? Yes Example Gi…
62. Search in Rotated Sorted Array[medium] Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array return its index, ot…
74. First Bad Version [medium] The code base version is an integer start from 1 to n. One day, someone committed a bad version in the code case, so it caused this version and the following versions are all failed in the unit tests. Find the first bad…