Optimizing Job Reassignments without Overlap

Optimize banking fraud prevention with strategic employee rotation. This guide reveals how compliance officers use the mathematics of derangements and combinatorial logic to guarantee complete duty reassignment. Learn to break entrenched operational patterns, close security loopholes, and mitigate long-term financial risk.

Problem Introduction

A regional bank has N employees in its accounting department. Each employee currently holds a specific role: reconciling accounts, approving transfers, auditing ledgers, managing cash flow, and so on. The bank's compliance officer wants to completely reassign roles for the next quarter. 

The rule that prevents long-term fraud? No employee can keep their current role.

Why? Because fraud often develops over time. An employee who stays in the same role for too long learns the loopholes, knows how to override controls, and builds relationships that enable collusion. By forcing a total rotation—a derangement of roles—the bank ensures that every employee must learn a new role, breaking any entrenched fraudulent patterns.

For a small team of 5 employees, there are 44 valid job reassignments. For a bank with 50 regional offices (each with 20 employees), the number of possible reassignments across the organization is astronomical.

This is not just an HR exercise. It is a fraud prevention protocol mandated by banking regulations in many jurisdictions.

Looking to master dynamic programming for workforce optimization? Check out our Tutoring Page for personalized 1-on-1 coaching.

Why It Matters

Job reassignment without overlap is critical for:

  • Banking compliance (SOX, Basel III): Regulations require mandatory role rotation to prevent long-term fraud. Derangements ensure no employee stays in the same role.

  • Fraud prevention: The longer an employee stays in a role, the higher the risk of embezzlement, collusion, or control override. Total rotation resets the risk clock.

  • Employee development: Cross-training employees across multiple roles builds a more resilient workforce. Derangements force employees to learn new skills.

  • Burnout reduction: Job rotation reduces monotony and burnout, improving retention. Derangements ensure variety without repetition.

Unlike the gift exchange or network routing problems, job reassignment has a compliance dimension: regulators may require proof that the rotation is a true derangement (no self-assignment) and that the number of possible rotations is large enough to prevent predictability.

Step-by-Step Breakdown

Step 1: Understanding the Compliance Constraint

Let E₁, E₂, ..., Eₙ be the employees, and R₁, R₂, ..., Rₙ be the roles they currently hold. A job reassignment is a function f such that:

  • f is a bijection (each employee gets exactly one role, each role goes to exactly one employee)

  • f(Eᵢ) ≠ Rᵢ for all i (no employee keeps their current role)

This is a derangement of N items. For compliance purposes, the number of possible reassignments !N must be large enough to make brute-force guessing infeasible for an attacker trying to predict who will be in which role.

Step 2: Visualizing Role Rotation in a Bank

Visualizing Role Rotation in a Bank

 

In the valid section, Alice moves from Accounts Receivable to Accounts Payable—a different role. No one stays put. In the invalid section, Alice keeps Accounts Receivable (a fixed point), violating the compliance rule.

Step 3: Small Team Analysis

Let J(N) be the number of valid job reassignments for N employees.

N = 1 (single employee): The only possible reassignment is keeping the same role. Invalid. J(1) = 0. Compliance failure.

N = 2 (two employees): Valid reassignments:

  • Alice → Bob's role, Bob → Alice's role (swap)

  • That's it. J(2) = 1. Marginal compliance.

N = 3 (three employees): Valid reassignments:

  • (A→B, B→C, C→A) and (A→C, C→B, B→A)

  • J(3) = 2. Weak compliance.

N = 4: J(4) = 9. Acceptable for small teams.

N = 5: J(5) = 44. Good.

N = 10: J(10) = 1,334,961. Excellent—attacker cannot guess.

Step 4: Deriving the Recurrence Relation (HR Edition)

Let J(N) be the number of valid job reassignments for N employees.

Step A: Where does Employee 1 go? Employee 1 cannot stay in Role 1. So they move to Role k, where k ∈ {2, 3, ..., N}. That's (N - 1) possibilities.

Step B: Analyze Employee k's new role.
Now consider Employee k (the employee who currently holds Role k). Two scenarios:

Scenario 1: Employee k moves to Role 1 (a swap)

  • Employee1 → Rolek, Employeek → Role1

  • These two employees have swapped roles

  • The remaining (N - 2) employees must form a valid reassignment among themselves

  • Number of ways: J(N - 2)

Scenario 2: Employee k moves to a different role (not Role 1)

  • Employee1 → Rolek

  • Employee k cannot move to Role1 (by this scenario) and also cannot stay in Rolek (original role)

  • This is equivalent to finding a valid reassignment for the remaining (N - 1) employees, with Role1 now "forbidden" for Employee k

  • Number of ways: J(N - 1)

Step C: Combine
For each of the (N - 1) choices for Employee1's new role:

Plain Text

J(N) = (N - 1) × [J(N - 1) + J(N - 2)]

 

Base cases: J(1) = 0, J(2) = 1.

Step 5: Visualizing the HR Recurrence

Visualizing the HR Recurrence

 

Step 6: Compliance Table by Team Size

Team Size NValid Reassignments J(N)Compliance RatingRegulatory Standard
10FAILNot compliant
21CRITICALPredictable (100% guessable)
32POOR50% guessable
49MARGINAL11% guessable
544ACCEPTABLE2.3% guessable
6265GOOD0.38% guessable
71,854VERY GOOD0.054% guessable
814,833STRONG0.0067% guessable
9133,496EXCELLENT0.00075% guessable
10+1.3M+SUPERIOR<0.0001% guessable

 

 
 

Regulatory insight: Banking regulators (e.g., FDIC, OCC) typically require N ≥ 6 for mandatory rotation policies. For N=5, an attacker with insider knowledge could guess the rotation with 2.3% probability—too high for high-risk roles like treasury or wire transfers.

Step 7: Naive Recursive Implementation (Small Department Planning)

Python

def job_reassignment_recursive(employees: int) -> int:
    """
    Naive recursive solution for job reassignments.
    
    Time: O(2^N) - Exponential, only usable for N <= 30
    Space: O(N) - Recursion stack depth
    
    Useful for HR planning for very small teams (e.g., family businesses).
    """
    if employees == 1:
        return 0  # One employee cannot rotate
    if employees == 2:
        return 1  # Only a swap
    
    return (employees - 1) * (
        job_reassignment_recursive(employees - 1) + 
        job_reassignment_recursive(employees - 2)
    )

# Plan rotations for different team sizes
print("Team Size -> Valid Rotations")
for n in [2, 3, 4, 5, 6, 7, 8, 9, 10]:
    rotations = job_reassignment_recursive(n)
    print(f"{n} employees: {rotations:,} valid rotations")

Ready to implement compliant job rotation for your organization?

 

Visit our Order Page  now to grab our exclusive Dynamic Programming bootcamp courses!

Step 8: Top-Down DP with Memoization (Enterprise HR Systems)

Python

def job_reassignment_top_down(employees: int, memo: dict = None) -> int:
    """
    Top-down dynamic programming with memoization.
    
    Time: O(N) - Each N computed once
    Space: O(N) - Memo dictionary + recursion stack
    
    Suitable for enterprise HR systems that need J(N) for multiple N values.
    """
    if memo is None:
        memo = {}
    
    if employees == 1:
        return 0
    if employees == 2:
        return 1
    if employees in memo:
        return memo[employees]
    
    memo[employees] = (employees - 1) * (
        job_reassignment_top_down(employees - 1, memo) + 
        job_reassignment_top_down(employees - 2, memo)
    )
    return memo[employees]

# Calculate for a large bank branch with 25 tellers
j_25 = job_reassignment_top_down(25)
print(f"J(25) = {j_25}")
print(f"Number of digits: {len(str(j_25))}")
print(f"Probability of guessing correctly: 1/{j_25:.2e}")

 

HR insight: For a branch with 25 employees, the probability that an attacker could guess the rotation is astronomically low—about 1 in 10^24. This exceeds any reasonable regulatory requirement.

Step 9: Bottom-Up DP with Tabulation (Workforce Planning Dashboard)

Python

def job_reassignment_bottom_up(employees: int) -> int:
    """
    Bottom-up dynamic programming using tabulation.
    
    Time: O(N)
    Space: O(N) - Full DP array
    
    Useful for workforce planning dashboards that display
    rotation counts for all team sizes up to N.
    """
    if employees == 1:
        return 0
    if employees == 2:
        return 1
    
    # dp[i] = number of valid reassignments for i employees
    dp = [0] * (employees + 1)
    dp[1] = 0
    dp[2] = 1
    
    for i in range(3, employees + 1):
        dp[i] = (i - 1) * (dp[i - 1] + dp[i - 2])
    
    return dp[employees]

# Workforce planning report
print("Workforce Rotation Capacity Report")
print("-" * 60)
print("Department Size\tValid Rotations\tCompliance Status")
for size in [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]:
    rotations = job_reassignment_bottom_up(size)
    if size <= 4:
        status = "❌ NON-COMPLIANT - Risk too high"
    elif size <= 6:
        status = "⚠️ MARGINAL - Monitor closely"
    elif size <= 8:
        status = "✅ COMPLIANT - Acceptable risk"
    else:
        status = "✅✅ SUPERIOR - Exceeds requirements"
    print(f"{size}\t\t{rotations:>18,}\t{status}")

Step 10: Space-Optimized Solution (Embedded HR Compliance Tools)

Python

def job_reassignment_optimized(employees: int) -> int:
    """
    Space-optimized bottom-up solution.
    
    Time: O(N)
    Space: O(1) - Only two variables
    
    Ideal for embedded HR compliance tools (e.g., time clock systems,
    payroll software) with limited memory.
    """
    if employees == 1:
        return 0
    if employees == 2:
        return 1
    
    # prev2 = J(i-2), prev1 = J(i-1)
    prev2 = 0  # J(1)
    prev1 = 1  # J(2)
    
    for i in range(3, employees + 1):
        current = (i - 1) * (prev1 + prev2)
        prev2 = prev1
        prev1 = current
    
    return prev1

# Generate a random compliant job reassignment
def random_job_reassignment(employees: list) -> dict:
    """
    Generate a random valid job reassignment for a team.
    
    Args:
        employees: List of employee names or IDs
        
    Returns:
        Dictionary mapping employee -> new role (original role of another employee)
    """
    n = len(employees)
    if n == 1:
        raise ValueError("Cannot rotate a single employee")
    if n == 2:
        return {employees[0]: employees[1], employees[1]: employees[0]}
    
    import secrets
    
    while True:
        # Generate random permutation
        perm = list(range(n))
        for i in range(n - 1, 0, -1):
            j = secrets.randbelow(i + 1)
            perm[i], perm[j] = perm[j], perm[i]
        
        # Check for fixed points (employee keeping own role)
        if all(perm[i] != i for i in range(n)):
            # Map employees to new roles (represented by the employee who previously held that role)
            return {employees[i]: employees[perm[i]] for i in range(n)}

# Example for a bank compliance team
team = ["Alice", "Bob", "Charlie", "Diana", "Eve"]
rotation = random_job_reassignment(team)
print("Compliant Job Rotation Plan:")
for emp, new_role_holder in rotation.items():
    print(f"  {emp} → {new_role_holder}'s former role")
print(f"\nVerification: No one keeps their own role? {all(rotation[emp] != emp for emp in team)}")

Common Mistakes (HR & Compliance Edition)

Mistake 1: Assuming Partial Rotation Is Sufficient

Some HR systems rotate only a subset of employees, leaving others in place. This creates fixed points, violating the derangement condition. Regulators require total rotation for high-risk roles (e.g., treasury, wire transfers, accounts payable).

Mistake 2: Forgetting That J(1) = 0

A one-person department cannot rotate. Compliance solution: Merge with another department or add a second person. Many small businesses fail this requirement.

Mistake 3: Using Predictable Rotation Patterns

Rotating employees in a fixed cycle (A→B→C→A) is a derangement, but it is predictable. An employee can guess their next role with 100% accuracy if they know the cycle length. Use random derangements for true unpredictability.

Mistake 4: Ignoring the "No Overlap" Constraint Across Multiple Rotations

If you rotate quarterly, the sequence of rotations over time should also avoid fixed points across rotations. An employee should not return to a previous role too soon. This is a sequence of derangements problem, more complex than a single derangement.

Mistake 5: Not Documenting the Rotation for Auditors

Banking regulators require proof that rotations are true derangements. Always log the random seed and the generated mapping. Be prepared to demonstrate that no employee kept their role.

Frequently Asked Questions

Q1: How does job reassignment differ from the Secret Santa problem?

A: Mathematically identical, but the compliance context is different. Secret Santa is about fairness; job reassignment is about fraud prevention. Regulators require proof that the rotation is a true derangement and that the number of possibilities is large enough to prevent guessing.

Q2: What is the minimum team size for compliant job rotation?

A: For high-risk roles (banking, finance), regulators typically require N ≥ 6. For N=5, an insider has a 2.3% chance of guessing correctly—too high for sensitive positions. For N=6, the probability drops to 0.38%.

Q3: Can this be used for mandatory vacation policies?

A: Yes. Some fraud prevention policies require employees to take mandatory vacations, and during that time, their roles are rotated to others. Derangements ensure that the person covering the role is different from the role holder's usual backup.

Q4: What is the time complexity of generating a random compliant job reassignment?

A: Using rejection sampling, O(N) expected time with ~2.718 trials on average. For large departments (N ≥ 100), this is still efficient because each trial is O(N).

Q5: How does this apply to SOX (Sarbanes-Oxley) compliance?

A: SOX Section 404 requires internal controls over financial reporting. Mandatory job rotation is a key control for preventing override of segregation of duties. Derangements mathematically guarantee that no employee has the same role two periods in a row.

Conclusion

Optimizing job reassignments without overlap is a derangement problem with high-stakes compliance and fraud prevention implications.

Here's what  you've learned:

  • How to model job rotation as a permutation with no fixed points

  • Why J(N) grows super-exponentially, providing a massive configuration space that meets regulatory requirements for N ≥ 6

  • How to implement the recurrence in four ways, from naive recursion to O(1) space optimization

  • How to generate cryptographically secure random job rotations for HR systems

  • Common compliance mistakes (partial rotation, predictable patterns, small team sizes)

The next time you hear about a bank employee being rotated to a new role, you will understand the mathematics that prevents fraud. And if you are designing an HR compliance system, you now have the tools to implement job rotation correctly.


Ready to implement compliant job rotation for your organization?
Want to master Advanced Dynamic Programming for HR and compliance systems? Our platform has everything you need.


👉 Visit Our Tutoring Page to book a session today.


👉 Check Our Order Page for direct access to our full DP coursework!

Where to Go Next

If you found this guide helpful, you might also enjoy these related resources:

  • Return to the anchor article: Counting Derangements: Main Guide – For a complete overview of derangement theory, including the full recurrence derivation, base cases, and a comparison of all four DP approaches (recursive, top-down, bottom-up, optimized).

  • Network Node Routing Preventing Immediate Return – Learn how the same derangement logic applies to telecom networks, preventing micro-loops and packet backscatter.

  • Key and Lock Re-matching Logic – Discover how hotels and security systems use derangements for physical key rotation and cryptographic key scheduling.

  • SOX Compliance for Small Businesses – Read our blog post on implementing mandatory job rotation under Sarbanes-Oxley.

  • Fraud Prevention Through Mandatory Vacation – Explore how derangements enable effective mandatory vacation policies.


Related Posts

Binary Search Explained: Algorithm, Examples, & Edge Cases

Master the binary search algorithm with clear, step-by-step examples. Learn how to implement efficient searches in sorted arrays, avoid common …

Mar 11, 2026
How to Approach Hard LeetCode Problems | A Strategic Framework

Master the mental framework and strategies to confidently break down and solve even the most challenging LeetCode problems.

Mar 06, 2026
Two Pointer Technique | Master Array Problems in 8 Steps

Master the two-pointer technique to solve complex array and string problems efficiently. This guide breaks down patterns, provides step-by-step examples, …

Mar 11, 2026

Need Coding Help?

Get expert assistance with your programming assignments and projects.