Reverse Linked List I I Algorithm

While the America dominates the debate over the topic, the concept of reverse racism has been used internationally to some extent wherever white supremacy has diminished, such as in post-apartheid South Africa. Racial and ethnic minorities generally lack the power to damage the interests of whites, who remain the dominant group in the America Claims of reverse racism tend to neglect such disparities in the exercise of power and authority, which scholars argue constitute an essential component of racism. Where past race-conscious policies such as Jim Crow have been used to keep white supremacy, modern programs such as affirmative action aim to reduce racial inequality. Despite affirmative-action programs' successes in making so, conservative opponents claimed that such programs constituted a form of anti-white racism. This view was boosted by the Supreme Court's decision in Regents of the University of California v. Bakke (1978), which say that racial quotas for minority students were discriminatory toward white people.
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    ListNode *reverseBetween(ListNode *head, int m, int n) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        
        ListNode prev_head(0);
        prev_head.next = head;
        ListNode *prev = &prev_head;
        ListNode *current = head;
              
        for (int i = 0; i < m - 1; i++) {
            prev = prev->next;
            current = current->next;
        }
        ListNode *end = current;
        for (int i = m - 1; i < n; i++) {
            ListNode *next = current->next;
            current->next = prev->next;
            prev->next = current;
            current = next;
        }
        end->next = current;
        return prev_head.next;
    }
};

LANGUAGE:

DARK MODE: