コード例 #1
0
 static void Main(string[] args)
 {
     RandomizedSet obj     = new RandomizedSet();
     bool          param_1 = obj.Insert(0);
     int           val     = obj.GetRandom();
     bool          param_2 = obj.Remove(0);
     bool          param_3 = obj.Insert(0);
 }
コード例 #2
0
        public void RandomizedSetTest()
        {
            var rs = new RandomizedSet();

            Assert.True(rs.Insert(1));
            Assert.False(rs.Remove(2));
            Assert.True(rs.Insert(2));
            Assert.True(new List <int> {
                1, 2
            }.Any(i => i == rs.GetRandom()));
            Assert.True(rs.Remove(1));
            Assert.False(rs.Insert(2));
            Assert.True(new List <int> {
                2
            }.Any(i => i == rs.GetRandom()));

            // Failed test case 18/18 https://leetcode.com/submissions/detail/352679922
        }