Skip to content

Commit bf8ef0e

Browse files
authored
2025-03-06 v. 8.8.4: added "1823. Find the Winner of the Circular Game"
2 parents 19ed489 + 67e63cb commit bf8ef0e

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
717717
| 1780. Check if Number is a Sum of Powers of Three | [Link](https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three/) | [Link](./lib/medium/1780_check_if_number_is_a_sum_of_powers_of_three.rb) | [Link](./test/medium/test_1780_check_if_number_is_a_sum_of_powers_of_three.rb) |
718718
| 1797. Design Authentication Manager | [Link](https://leetcode.com/problems/design-authentication-manager/) | [Link](./lib/medium/1797_design_authentication_manager.rb) | [Link](./test/medium/test_1797_design_authentication_manager.rb) |
719719
| 1814. Count Nice Pairs in an Array | [Link](https://leetcode.com/problems/count-nice-pairs-in-an-array/) | [Link](./lib/medium/1814_count_nice_pairs_in_an_array.rb) | [Link](./test/medium/test_1814_count_nice_pairs_in_an_array.rb) |
720+
| 1823. Find the Winner of the Circular Game | [Link](https://leetcode.com/problems/find-the-winner-of-the-circular-game/) | [Link](./lib/medium/1823_find_the_winner_of_the_circular_game.rb) | [Link](./test/medium/test_1823_find_the_winner_of_the_circular_game.rb) |
720721
| 2116. Check if a Parentheses String Can Be Valid | [Link](https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid/) | [Link](./lib/medium/2116_check_if_a_parentheses_string_can_be_valid.rb) | [Link](./test/medium/test_2116_check_if_a_parentheses_string_can_be_valid.rb) |
721722
| 2425. Bitwise XOR of All Pairings | [Link](https://leetcode.com/problems/bitwise-xor-of-all-pairings/) | [Link](./lib/medium/2425_bitwise_xor_of_all_pairings.rb) | [Link](./test/medium/test_2425_bitwise_xor_of_all_pairings.rb) |
722723
| 2429. Minimize XOR | [Link](https://leetcode.com/problems/minimize-xor/) | [Link](./lib/medium/2429_minimize_xor.rb) | [Link](./test/medium/test_2429_minimize_xor.rb) |

leetcode-ruby.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'English'
55
::Gem::Specification.new do |s|
66
s.required_ruby_version = '>= 3.0'
77
s.name = 'leetcode-ruby'
8-
s.version = '8.8.3'
8+
s.version = '8.8.4'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[README.md]
1111
s.executable = 'leetcode-ruby'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
# https://leetcode.com/problems/find-the-winner-of-the-circular-game/
4+
# @param {Integer} n
5+
# @param {Integer} k
6+
# @return {Integer}
7+
def find_the_winner(n, k)
8+
return 1 if n == 1
9+
10+
(find_the_winner(n - 1, k) + k - 1) % n + 1
11+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/medium/1823_find_the_winner_of_the_circular_game'
5+
require 'minitest/autorun'
6+
7+
class FindTheWinnerOfTheCircularGameTest < ::Minitest::Test
8+
def test_default_one = assert_equal(3, find_the_winner(5, 2))
9+
10+
def test_default_two = assert_equal(1, find_the_winner(6, 5))
11+
end

0 commit comments

Comments
 (0)