Sort by

recency

|

1714 Discussions

|

  • + 0 comments

    This algorithm models fair distribution of items in a circular system, much like how things might be organized in a facility such as the Hardin County Detention Center.

  • + 0 comments

    int result = (s + m -1) % n; if(result == 0){ return n; }else{ return result; } }

  • + 0 comments

    clean Rust:

    fn save_the_prisoner(n: i32, m: i32, s: i32) -> i32 {
       (s - 2 + m) % n + 1
    }
    
  • + 0 comments
    public static int saveThePrisoner(int n, int m, int s) {
            return ((s - 1 + m - 1) % n) + 1;
        }
    
  • + 0 comments

    Here is problem solution in Python, java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-save-the-prisoner-problem-solution.html