Detect permutation in linked list

Last updated: September 12, 2025

Quick Overview

Given a linked list and a string, determine if any contiguous subsequence of the linked list's values forms a permutation of the string. The linked list is composed of characters, and the output should indicate whether such a permutation exists (true or false).

PayPal
Coding & Algorithms
Software Engineer
PayPal
September 12, 2025
Software Engineer
Phone Screen
Coding & Algorithms
Hard

139

2

2,893 solved


Given a linked list and a string, determine if any contiguous subsequence of the linked list's values forms a permutation of the string. The linked list is composed of characters, and the output should indicate whether such a permutation exists (true or false).

Coding interviews at PayPal focus on problem-solving approach as much as the final solution. The interviewer wants to see you break down the problem, consider edge cases, and optimize iteratively. Communication throughout the process is key.

What the Interviewer Expects
  • Quickly identify the optimal approach and its theoretical basis
  • Handle complex algorithm design with multiple interacting components
  • Write concise, elegant code under time pressure
  • Prove correctness of your approach and discuss alternative solutions
  • Optimize beyond the obvious: discuss constant factor improvements
  • Address follow-up variations and explain how the solution generalizes
Key Topics to Cover
Dynamic programming and memoization
Edge cases and input validation
Graph algorithms and traversal
Tree structures and recursion
Time and space complexity analysis
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What happens if the input contains duplicates?
  • Can you solve this in a single pass?
  • How would you parallelize this solution?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Problem Analysis

To determine if any contiguous subsequence of the linked list's values forms a permutation of a given string, we can utilize the sliding window technique combined with **character frequency counti...

Approach
  1. Initialize a frequency counter for the string using a dictionary to count occurrences of each character.
  2. Create a sliding window of size equal to the length of the string and start from the beg...

Submit Your Answer
Markdown supported

Related Questions