[LeetCode] Count Houses in a Circular Street

2728. Count Houses in a Circular Street

You are given an object street of class Street that represents a circular street and a positive integer k which represents a maximum bound for the number of houses in that street (in other words, the number of houses is less than or equal to k). Houses’ doors could be open or closed initially.

Initially, you are standing in front of a door to a house on this street. Your task is to count the number of houses in the street.

The class Street contains the following functions which may help you:

  • void openDoor(): Open the door of the house you are in front of.
  • void closeDoor(): Close the door of the house you are in front of.
  • boolean isDoorOpen(): Returns true if the door of the current house is open and false otherwise.
  • void moveRight(): Move to the right house.
  • void moveLeft(): Move to the left house.

Return ans which represents the number of houses on this street.

Read more
[LeetCode] Count Numbers With Unique Digits II

3032. Count Numbers With Unique Digits II

Given two positive integers a and b, return the count of numbers having unique digits in the range [a, b] (inclusive).

Read more
[System Design] Design Distributed Counter

Design Distributed Counter

Read more
[Codeforces] Helvetic Coding Contest 2024 online mirror (teams allowed, unrated) C3. Game on Tree (Hard)Read more
[Codeforces] Helvetic Coding Contest 2024 online mirror (teams allowed, unrated) C2. Game on Tree (Medium)Read more
[Codeforces] Educational Round 165 (Rated for Div. 2) C. Minimizing the SumRead more
[Codeforces] Round 943 (Div. 3) F. Equal XOR SegmentsRead more
[Codeforces] Round 943 (Div. 3) E. Cells ArrangementRead more
[LeetCode] Find the Minimum Cost Array Permutation

3149. Find the Minimum Cost Array Permutation

You are given an array nums which is a permutation of [0, 1, 2, ..., n - 1]. The score of any permutation of [0, 1, 2, ..., n - 1] named perm is defined as:

1
>score(perm) = |perm[0] - nums[perm[1]]| + |perm[1] - nums[perm[2]]| + ... + |perm[n - 1] - nums[perm[0]]|

Return the permutation perm which has the minimum possible score. If multiple permutations exist with this score, return the one that is lexicographically smallest among them.

Read more
[LeetCode] Maximum Difference Score in a Grid

3148. Maximum Difference Score in a Grid

You are given an m x n matrix grid consisting of positive integers. You can move from a cell in the matrix to any other cell that is either to the bottom or to the right (not necessarily adjacent). The score of a move from a cell with the value c1 to a cell with the value c2 is c2 - c1.

You can start at any cell, and you have to make at least one move.

Return the maximum total score you can achieve.

Read more