Skip to content

Commit b9dd9ca

Browse files
authored
Added tasks 3232-3235
1 parent 46ba3a9 commit b9dd9ca

File tree

5 files changed

+542
-108
lines changed
  • src/main/kotlin/g3201_3300
    • s3232_find_if_digit_game_can_be_won
    • s3233_find_the_count_of_numbers_which_are_not_special
    • s3234_count_the_number_of_substrings_with_dominant_ones
    • s3235_check_if_the_rectangle_corner_is_reachable

5 files changed

+542
-108
lines changed

README.md

Lines changed: 112 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork)
33
> ["For coding interview preparation, LeetCode is one of the best online resource providing a rich library of more than 300 real coding interview questions for you to practice from using one of the 7 supported languages - C, C++, Java, Python, C#, JavaScript, Ruby."](https://www.quora.com/How-effective-is-Leetcode-for-preparing-for-technical-interviews)
44

5-
* [Level 1](#level-1)
65
* [Level 2](#level-2)
76
* [Udemy](#udemy)
87
* [Data Structure I](#data-structure-i)
@@ -16,113 +15,7 @@
1615
* [Programming Skills II](#programming-skills-ii)
1716
* [Graph Theory I](#graph-theory-i)
1817
* [SQL I](#sql-i)
19-
20-
### Level 1
21-
22-
#### Day 1 Prefix Sum
23-
24-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
25-
|-|-|-|-|-|-
26-
| 1480 |[Running Sum of 1d Array](src/main/kotlin/g1401_1500/s1480_running_sum_of_1d_array)| Easy | Array, Prefix_Sum | 161 | 84.80
27-
| 0724 |[Find Pivot Index](src/main/kotlin/g0701_0800/s0724_find_pivot_index)| Easy | Array, Prefix_Sum | 255 | 88.92
28-
29-
#### Day 2 String
30-
31-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
32-
|-|-|-|-|-|-
33-
| 0205 |[Isomorphic Strings](src/main/kotlin/g0201_0300/s0205_isomorphic_strings)| Easy | String, Hash_Table | 278 | 79.96
34-
| 0392 |[Is Subsequence](src/main/kotlin/g0301_0400/s0392_is_subsequence)| Easy | String, Dynamic_Programming, Two_Pointers | 156 | 87.74
35-
36-
#### Day 3 Linked List
37-
38-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
39-
|-|-|-|-|-|-
40-
| 0021 |[Merge Two Sorted Lists](src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 157 | 92.24
41-
| 0206 |[Reverse Linked List](src/main/kotlin/g0201_0300/s0206_reverse_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 279 | 45.78
42-
43-
#### Day 4 Linked List
44-
45-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
46-
|-|-|-|-|-|-
47-
| 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52
48-
| 0142 |[Linked List Cycle II](src/main/kotlin/g0101_0200/s0142_linked_list_cycle_ii)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 192 | 63.39
49-
50-
#### Day 5 Greedy
51-
52-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
53-
|-|-|-|-|-|-
54-
| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 609 | 94.06
55-
| 0409 |[Longest Palindrome](src/main/kotlin/g0401_0500/s0409_longest_palindrome)| Easy | String, Hash_Table, Greedy | 259 | 60.71
56-
57-
#### Day 6 Tree
58-
59-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
60-
|-|-|-|-|-|-
61-
| 0589 |[N-ary Tree Preorder Traversal](src/main/kotlin/g0501_0600/s0589_n_ary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Stack | 233 | 84.02
62-
| 0102 |[Binary Tree Level Order Traversal](src/main/kotlin/g0101_0200/s0102_binary_tree_level_order_traversal)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 198 | 95.14
63-
64-
#### Day 7 Binary Search
65-
66-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
67-
|-|-|-|-|-|-
68-
| 0704 |[Binary Search](src/main/kotlin/g0701_0800/s0704_binary_search)| Easy | Top_100_Liked_Questions, Array, Binary_Search | 261 | 77.91
69-
| 0278 |[First Bad Version](src/main/kotlin/g0201_0300/s0278_first_bad_version)| Easy | Binary_Search, Interactive | 349 | 76.86
70-
71-
#### Day 8 Binary Search Tree
72-
73-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
74-
|-|-|-|-|-|-
75-
| 0098 |[Validate Binary Search Tree](src/main/kotlin/g0001_0100/s0098_validate_binary_search_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 190 | 61.62
76-
| 0235 |[Lowest Common Ancestor of a Binary Search Tree](src/main/kotlin/g0201_0300/s0235_lowest_common_ancestor_of_a_binary_search_tree)| Medium | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 404 | 75.59
77-
78-
#### Day 9 Graph/BFS/DFS
79-
80-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
81-
|-|-|-|-|-|-
82-
| 0733 |[Flood Fill](src/main/kotlin/g0701_0800/s0733_flood_fill)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 230 | 97.76
83-
| 0200 |[Number of Islands](src/main/kotlin/g0101_0200/s0200_number_of_islands)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 252 | 95.41
84-
85-
#### Day 10 Dynamic Programming
86-
87-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
88-
|-|-|-|-|-|-
89-
| 0509 |[Fibonacci Number](src/main/kotlin/g0501_0600/s0509_fibonacci_number)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 139 | 82.72
90-
| 0070 |[Climbing Stairs](src/main/kotlin/g0001_0100/s0070_climbing_stairs)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 124 | 71.98
91-
92-
#### Day 11 Dynamic Programming
93-
94-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
95-
|-|-|-|-|-|-
96-
| 0746 |[Min Cost Climbing Stairs](src/main/kotlin/g0701_0800/s0746_min_cost_climbing_stairs)| Easy | Array, Dynamic_Programming | 171 | 96.76
97-
| 0062 |[Unique Paths](src/main/kotlin/g0001_0100/s0062_unique_paths)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 118 | 94.65
98-
99-
#### Day 12 Sliding Window/Two Pointer
100-
101-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
102-
|-|-|-|-|-|-
103-
| 0438 |[Find All Anagrams in a String](src/main/kotlin/g0401_0500/s0438_find_all_anagrams_in_a_string)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 561 | 54.68
104-
| 0424 |[Longest Repeating Character Replacement](src/main/kotlin/g0401_0500/s0424_longest_repeating_character_replacement)| Medium | String, Hash_Table, Sliding_Window | 288 | 84.38
105-
106-
#### Day 13 Hashmap
107-
108-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
109-
|-|-|-|-|-|-
110-
| 0001 |[Two Sum](src/main/kotlin/g0001_0100/s0001_two_sum)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 202 | 91.18
111-
| 0299 |[Bulls and Cows](src/main/kotlin/g0201_0300/s0299_bulls_and_cows)| Medium | String, Hash_Table, Counting | 254 | 84.82
112-
113-
#### Day 14 Stack
114-
115-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
116-
|-|-|-|-|-|-
117-
| 0844 |[Backspace String Compare](src/main/kotlin/g0801_0900/s0844_backspace_string_compare)| Easy | String, Two_Pointers, Stack, Simulation | 126 | 98.31
118-
| 0394 |[Decode String](src/main/kotlin/g0301_0400/s0394_decode_string)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 224 | 64.86
119-
120-
#### Day 15 Heap
121-
122-
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
123-
|-|-|-|-|-|-
124-
| 1046 |[Last Stone Weight](src/main/kotlin/g1001_1100/s1046_last_stone_weight)| Easy | Array, Heap_Priority_Queue | 123 | 100.00
125-
| 0692 |[Top K Frequent Words](src/main/kotlin/g0601_0700/s0692_top_k_frequent_words)| Medium | String, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Trie, Bucket_Sort | 239 | 81.10
18+
* [Level 1](#level-1)
12619

12720
### Level 2
12821

@@ -1812,10 +1705,121 @@
18121705
| 1587 |[Bank Account Summary II](src/main/kotlin/g1501_1600/s1587_bank_account_summary_ii)| Easy | Database | 1582 | 52.96
18131706
| 1084 |[Sales Analysis III](src/main/kotlin/g1001_1100/s1084_sales_analysis_iii)| Easy | LeetCode_Curated_SQL_70, Database | 1881 | 79.36
18141707

1708+
### Level 1
1709+
1710+
#### Day 1 Prefix Sum
1711+
1712+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1713+
|-|-|-|-|-|-
1714+
| 1480 |[Running Sum of 1d Array](src/main/kotlin/g1401_1500/s1480_running_sum_of_1d_array)| Easy | Array, Prefix_Sum | 161 | 84.80
1715+
| 0724 |[Find Pivot Index](src/main/kotlin/g0701_0800/s0724_find_pivot_index)| Easy | Array, Prefix_Sum | 255 | 88.92
1716+
1717+
#### Day 2 String
1718+
1719+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1720+
|-|-|-|-|-|-
1721+
| 0205 |[Isomorphic Strings](src/main/kotlin/g0201_0300/s0205_isomorphic_strings)| Easy | String, Hash_Table | 278 | 79.96
1722+
| 0392 |[Is Subsequence](src/main/kotlin/g0301_0400/s0392_is_subsequence)| Easy | String, Dynamic_Programming, Two_Pointers | 156 | 87.74
1723+
1724+
#### Day 3 Linked List
1725+
1726+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1727+
|-|-|-|-|-|-
1728+
| 0021 |[Merge Two Sorted Lists](src/main/kotlin/g0001_0100/s0021_merge_two_sorted_lists)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(m+n)_Space_O(m+n) | 157 | 92.24
1729+
| 0206 |[Reverse Linked List](src/main/kotlin/g0201_0300/s0206_reverse_linked_list)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Linked_List, Recursion, Big_O_Time_O(N)_Space_O(1) | 279 | 45.78
1730+
1731+
#### Day 4 Linked List
1732+
1733+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1734+
|-|-|-|-|-|-
1735+
| 0876 |[Middle of the Linked List](src/main/kotlin/g0801_0900/s0876_middle_of_the_linked_list)| Easy | Two_Pointers, Linked_List | 136 | 76.52
1736+
| 0142 |[Linked List Cycle II](src/main/kotlin/g0101_0200/s0142_linked_list_cycle_ii)| Medium | Top_100_Liked_Questions, Hash_Table, Two_Pointers, Linked_List, Big_O_Time_O(N)_Space_O(1) | 192 | 63.39
1737+
1738+
#### Day 5 Greedy
1739+
1740+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1741+
|-|-|-|-|-|-
1742+
| 0121 |[Best Time to Buy and Sell Stock](src/main/kotlin/g0101_0200/s0121_best_time_to_buy_and_sell_stock)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Dynamic_Programming, Big_O_Time_O(N)_Space_O(1) | 609 | 94.06
1743+
| 0409 |[Longest Palindrome](src/main/kotlin/g0401_0500/s0409_longest_palindrome)| Easy | String, Hash_Table, Greedy | 259 | 60.71
1744+
1745+
#### Day 6 Tree
1746+
1747+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1748+
|-|-|-|-|-|-
1749+
| 0589 |[N-ary Tree Preorder Traversal](src/main/kotlin/g0501_0600/s0589_n_ary_tree_preorder_traversal)| Easy | Depth_First_Search, Tree, Stack | 233 | 84.02
1750+
| 0102 |[Binary Tree Level Order Traversal](src/main/kotlin/g0101_0200/s0102_binary_tree_level_order_traversal)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Breadth_First_Search, Tree, Binary_Tree, Big_O_Time_O(N)_Space_O(N) | 198 | 95.14
1751+
1752+
#### Day 7 Binary Search
1753+
1754+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1755+
|-|-|-|-|-|-
1756+
| 0704 |[Binary Search](src/main/kotlin/g0701_0800/s0704_binary_search)| Easy | Top_100_Liked_Questions, Array, Binary_Search | 261 | 77.91
1757+
| 0278 |[First Bad Version](src/main/kotlin/g0201_0300/s0278_first_bad_version)| Easy | Binary_Search, Interactive | 349 | 76.86
1758+
1759+
#### Day 8 Binary Search Tree
1760+
1761+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1762+
|-|-|-|-|-|-
1763+
| 0098 |[Validate Binary Search Tree](src/main/kotlin/g0001_0100/s0098_validate_binary_search_tree)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree, Big_O_Time_O(N)_Space_O(log(N)) | 190 | 61.62
1764+
| 0235 |[Lowest Common Ancestor of a Binary Search Tree](src/main/kotlin/g0201_0300/s0235_lowest_common_ancestor_of_a_binary_search_tree)| Medium | Depth_First_Search, Tree, Binary_Tree, Binary_Search_Tree | 404 | 75.59
1765+
1766+
#### Day 9 Graph/BFS/DFS
1767+
1768+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1769+
|-|-|-|-|-|-
1770+
| 0733 |[Flood Fill](src/main/kotlin/g0701_0800/s0733_flood_fill)| Easy | Array, Depth_First_Search, Breadth_First_Search, Matrix | 230 | 97.76
1771+
| 0200 |[Number of Islands](src/main/kotlin/g0101_0200/s0200_number_of_islands)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Array, Depth_First_Search, Breadth_First_Search, Matrix, Union_Find, Big_O_Time_O(M\*N)_Space_O(M\*N) | 252 | 95.41
1772+
1773+
#### Day 10 Dynamic Programming
1774+
1775+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1776+
|-|-|-|-|-|-
1777+
| 0509 |[Fibonacci Number](src/main/kotlin/g0501_0600/s0509_fibonacci_number)| Easy | Dynamic_Programming, Math, Recursion, Memoization | 139 | 82.72
1778+
| 0070 |[Climbing Stairs](src/main/kotlin/g0001_0100/s0070_climbing_stairs)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Memoization, Big_O_Time_O(n)_Space_O(n) | 124 | 71.98
1779+
1780+
#### Day 11 Dynamic Programming
1781+
1782+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1783+
|-|-|-|-|-|-
1784+
| 0746 |[Min Cost Climbing Stairs](src/main/kotlin/g0701_0800/s0746_min_cost_climbing_stairs)| Easy | Array, Dynamic_Programming | 171 | 96.76
1785+
| 0062 |[Unique Paths](src/main/kotlin/g0001_0100/s0062_unique_paths)| Medium | Top_100_Liked_Questions, Top_Interview_Questions, Dynamic_Programming, Math, Combinatorics, Big_O_Time_O(m\*n)_Space_O(m\*n) | 118 | 94.65
1786+
1787+
#### Day 12 Sliding Window/Two Pointer
1788+
1789+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1790+
|-|-|-|-|-|-
1791+
| 0438 |[Find All Anagrams in a String](src/main/kotlin/g0401_0500/s0438_find_all_anagrams_in_a_string)| Medium | Top_100_Liked_Questions, String, Hash_Table, Sliding_Window, Big_O_Time_O(n+m)_Space_O(1) | 561 | 54.68
1792+
| 0424 |[Longest Repeating Character Replacement](src/main/kotlin/g0401_0500/s0424_longest_repeating_character_replacement)| Medium | String, Hash_Table, Sliding_Window | 288 | 84.38
1793+
1794+
#### Day 13 Hashmap
1795+
1796+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1797+
|-|-|-|-|-|-
1798+
| 0001 |[Two Sum](src/main/kotlin/g0001_0100/s0001_two_sum)| Easy | Top_100_Liked_Questions, Top_Interview_Questions, Array, Hash_Table, Big_O_Time_O(n)_Space_O(n) | 202 | 91.18
1799+
| 0299 |[Bulls and Cows](src/main/kotlin/g0201_0300/s0299_bulls_and_cows)| Medium | String, Hash_Table, Counting | 254 | 84.82
1800+
1801+
#### Day 14 Stack
1802+
1803+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1804+
|-|-|-|-|-|-
1805+
| 0844 |[Backspace String Compare](src/main/kotlin/g0801_0900/s0844_backspace_string_compare)| Easy | String, Two_Pointers, Stack, Simulation | 126 | 98.31
1806+
| 0394 |[Decode String](src/main/kotlin/g0301_0400/s0394_decode_string)| Medium | Top_100_Liked_Questions, String, Stack, Recursion, Big_O_Time_O(n)_Space_O(n) | 224 | 64.86
1807+
1808+
#### Day 15 Heap
1809+
1810+
| <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- --> | <!-- -->
1811+
|-|-|-|-|-|-
1812+
| 1046 |[Last Stone Weight](src/main/kotlin/g1001_1100/s1046_last_stone_weight)| Easy | Array, Heap_Priority_Queue | 123 | 100.00
1813+
| 0692 |[Top K Frequent Words](src/main/kotlin/g0601_0700/s0692_top_k_frequent_words)| Medium | String, Hash_Table, Sorting, Heap_Priority_Queue, Counting, Trie, Bucket_Sort | 239 | 81.10
1814+
18151815
## Algorithms
18161816

18171817
| # | Title | Difficulty | Tag | Time, ms | Time, %
18181818
|------|----------------|-------------|-------------|----------|--------
1819+
| 3235 |[Check if the Rectangle Corner Is Reachable](src/main/kotlin/g3201_3300/s3235_check_if_the_rectangle_corner_is_reachable)| Hard | Array, Math, Depth_First_Search, Breadth_First_Search, Union_Find, Geometry | 612 | 66.67
1820+
| 3234 |[Count the Number of Substrings With Dominant Ones](src/main/kotlin/g3201_3300/s3234_count_the_number_of_substrings_with_dominant_ones)| Medium | String, Sliding_Window, Enumeration | 356 | 100.00
1821+
| 3233 |[Find the Count of Numbers Which Are Not Special](src/main/kotlin/g3201_3300/s3233_find_the_count_of_numbers_which_are_not_special)| Medium | Array, Math, Number_Theory | 215 | 76.19
1822+
| 3232 |[Find if Digit Game Can Be Won](src/main/kotlin/g3201_3300/s3232_find_if_digit_game_can_be_won)| Easy | Array, Math | 194 | 36.00
18191823
| 3229 |[Minimum Operations to Make Array Equal to Target](src/main/kotlin/g3201_3300/s3229_minimum_operations_to_make_array_equal_to_target)| Hard | Array, Dynamic_Programming, Greedy, Stack, Monotonic_Stack | 636 | 57.14
18201824
| 3228 |[Maximum Number of Operations to Move Ones to the End](src/main/kotlin/g3201_3300/s3228_maximum_number_of_operations_to_move_ones_to_the_end)| Medium | String, Greedy, Counting | 232 | 44.00
18211825
| 3227 |[Vowels Game in a String](src/main/kotlin/g3201_3300/s3227_vowels_game_in_a_string)| Medium | String, Math, Game_Theory, Brainteaser | 234 | 90.32
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[![](https://img.shields.io/github/stars/javadev/LeetCode-in-Kotlin?label=Stars&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin)
2+
[![](https://img.shields.io/github/forks/javadev/LeetCode-in-Kotlin?label=Fork%20me%20on%20GitHub%20&style=flat-square)](https://github.com/javadev/LeetCode-in-Kotlin/fork)
3+
4+
## 3232\. Find if Digit Game Can Be Won
5+
6+
Easy
7+
8+
You are given an array of **positive** integers `nums`.
9+
10+
Alice and Bob are playing a game. In the game, Alice can choose **either** all single-digit numbers or all double-digit numbers from `nums`, and the rest of the numbers are given to Bob. Alice wins if the sum of her numbers is **strictly greater** than the sum of Bob's numbers.
11+
12+
Return `true` if Alice can win this game, otherwise, return `false`.
13+
14+
**Example 1:**
15+
16+
**Input:** nums = [1,2,3,4,10]
17+
18+
**Output:** false
19+
20+
**Explanation:**
21+
22+
Alice cannot win by choosing either single-digit or double-digit numbers.
23+
24+
**Example 2:**
25+
26+
**Input:** nums = [1,2,3,4,5,14]
27+
28+
**Output:** true
29+
30+
**Explanation:**
31+
32+
Alice can win by choosing single-digit numbers which have a sum equal to 15.
33+
34+
**Example 3:**
35+
36+
**Input:** nums = [5,5,5,25]
37+
38+
**Output:** true
39+
40+
**Explanation:**
41+
42+
Alice can win by choosing double-digit numbers which have a sum equal to 25.
43+
44+
**Constraints:**
45+
46+
* `1 <= nums.length <= 100`
47+
* `1 <= nums[i] <= 99`
48+
49+
## Solution
50+
51+
```kotlin
52+
class Solution {
53+
fun canAliceWin(nums: IntArray): Boolean {
54+
var sdSum = 0
55+
var ddSum = 0
56+
for (num in nums) {
57+
if (num / 10 == 0) {
58+
sdSum += num
59+
} else {
60+
ddSum += num
61+
}
62+
}
63+
return sdSum != ddSum
64+
}
65+
}
66+
```

0 commit comments

Comments
 (0)