1.58K subscribers
598 photos
1 file
970 links
Don't miss a day to solve the problem
My leetcode graph - https://leetcode.com/SamoylenkoDmitry/
Download Telegram
Problem url: [Count of Matches in Tournament](https://leetcode.com/problems/count-of-matches-in-tournament/?envType=daily-question&envId=2023-12-05)
Text:
Given an integer n, the number of teams in a tournament. You need to return the number of matches played in the tournament until a winner is decided.

If the current number of teams is even, each team gets paired with another team. A total of n / 2 matches are played, and n / 2 teams advance to the next round.

If the current number of teams is odd, one team randomly advances in the tournament, and the rest gets paired. A total of (n - 1) / 2 matches are played, and (n - 1) / 2 + 1 teams advance to the next round.

Example 1:
Input: n = 7
Output: 6
Explanation:
- 1st Round: Teams = 7, Matches = 3, and 4 teams advance.
- 2nd Round: Teams = 4, Matches = 2, and 2 teams advance.
- 3rd Round: Teams = 2, Matches = 1, and 1 team is declared the winner.
Total number of matches = 3 + 2 + 1 = 6.

Constraints:
1 <= n <= 200
👍1
I am traveling, so here is a sunrise at 11 km, leetcode maybe later
🤝8🆒1
I think this easy week is somehow related to ongoing AdventOfCode 😉
🫡1
https://leetcode.com/problems/largest-odd-number-in-string/description/

Return the largest valued odd integer that is a non-empty substring of a given string num. If no odd integer exists, return an empty string.
👍1
https://leetcode.com/problems/construct-string-from-binary-tree/description/

606. Construct String from Binary Tree

Given the root of a binary tree, construct a string consisting of parenthesis and integers using the preorder traversal. Omit all unnecessary empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and the original binary tree.

Example 1:

Input: root = [1,2,3,4]
Output: "1(2(4))(3)"
Explanation: Originally, it needs to be "1(2(4)())(3()())", but you need to omit all the unnecessary empty parenthesis pairs. And it will be "1(2(4))(3)"

Example 2:

Input: root = [1,2,3,null,4]
Output: "1(2()(4))(3)"
Explanation: Almost the same as the first example, except we cannot omit the first parenthesis pair to break the one-to-one mapping relationship between the input and the output.

Constraints:

- The number of nodes in the tree is in the range [1, 104].
- Node.val is between -1000 and 1000.
👍1
https://leetcode.com/problems/binary-tree-inorder-traversal/description/

Binary Tree Inorder Traversal - Given the root of a binary tree, return the inorder traversal of its nodes' values.
👍1
https://leetcode.com/problems/destination-city/description/

Destination city in a paths[i] = [cityAi, cityBi] path
👍1
https://leetcode.com/problems/design-a-food-rating-system/description/

Given foods, cuisines and ratings implement efficient methods changeRating(food, newRating) and highestRated(cuisine)
👍1
👍1
👍1
https://leetcode.com/problems/path-crossing/description/

Is path string of 'N', 'E', 'W', 'S' crosses
👍1