Reverse Linked List 2 - between m and n

Problem Reverse a linked list from position m to n. Do it in-place and in one-pass. OR Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list. Examples Example 1: --- title: Input --- graph LR A1[1] --> B2[2]:::reversed --> C3[3]:::reversed --> D4[4]:::reversed --> E5[5] classDef reversed fill:#ffcc00,stroke:#000,stroke-width:2px; ...

Run-length Encoding

Problem Run-length Encoded is a fast and simple method of encoding strings. The basic idea is to represent repeated successive characters as a single count and character. Examples Example 1: Input: str = AAAABBBCCDAA Output: 4A3B2C1D2A Input Format public class RLECodec { public String encode(String str) { } public String decode(String data) { } } ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy