3274. Check if Two Chessboard Squares Have the Same Color using Rust

Freelancing diary placeholder featured image

0 Problem You are given two strings, coordinate1 and coordinate2, representing the coordinates of a square on an 8 x 8 chessboard. Below is the chessboard for reference. Return true if these two squares have the same color and false otherwise. The coordinate will always represent a valid chessboard square. The coordinate will always have the letter first (indicating its column), and the number … Read more

3264. Final Array State After K Multiplication Operations I using Rust

Freelancing diary placeholder featured image

0 Problem You are given an integer array nums, an integer k, and an integer multiplier. You need to perform k operations on nums. In each operation: Return an integer array denoting the final state of nums after performing all k operations. Example 1: Input: nums = [2,1,3,5,6], k = 5, multiplier = 2 Output: [8,4,6,5,6] Explanation: Operation Result After operation 1 [2, 2, 3, 5, 6] After operation … Read more

3242. Design Neighbor Sum Service using Rust

Freelancing diary placeholder featured image

0 Problem ou are given a n x n 2D array grid containing distinct elements in the range [0, n2 – 1]. Implement the NeighborSum class: Example 1: Input: [“NeighborSum”, “adjacentSum”, “adjacentSum”, “diagonalSum”, “diagonalSum”] [[[[0, 1, 2], [3, 4, 5], [6, 7, 8]]], [1], [4], [4], [8]] Output: [null, 6, 16, 16, 4] Explanation: Example 2: Input: [“NeighborSum”, “adjacentSum”, “diagonalSum”] [[[[1, 2, 0, 3], [4, … Read more

3248. Snake in Matrix using Rust

Freelancing diary placeholder featured image

0 Problem There is a snake in an n x n matrix grid and can move in four possible directions. Each cell in the grid is identified by the position: grid[i][j] = (i * n) + j. The snake starts at cell 0 and follows a sequence of commands. You are given an integer n representing the size of the grid and an array of strings commands where each command[i] is … Read more

3258. Count Substrings That Satisfy K-Constraint using Rust

Freelancing diary placeholder featured image

1 Problem You are given a binary string s and an integer k. A binary string satisfies the k-constraint if either of the following conditions holds: Return an integer denoting the number of  substrings of s that satisfy the k-constraint. Example 1: Input: s = “10101”, k = 1 Output: 12 Explanation: Every substring of s except the substrings “1010”, “10101”, and “0101” satisfies the k-constraint. Example 2: Input: s = “1010101”, k = 2 Output: 25 Explanation: Every substring … Read more

3210. Find the Encrypted String using Rust

Freelancing diary placeholder featured image

0 Problem You are given a string s and an integer k. Encrypt the string using the following algorithm: Return the encrypted string. Example 1: Input: s = “dart”, k = 3 Output: “tdar” Explanation: Example 2: Input: s = “aaa”, k = 1 Output: “aaa” Explanation: As all the characters are the same, the encrypted string will also be the same. Constraints: … Read more

3232. Find if Digit Game Can Be Won using JavaScript

0 Problem You are given an array of positive integers nums. 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. Return true if Alice … Read more

3216. Lexicographically Smallest String After a Swap using JavaScript

0 Problem Given a string s containing only digits, return the  lexicographically smallest string that can be obtained after swapping adjacent digits in s with the same parity at most once. Digits have the same parity if both are odd or both are even. For example, 5 and 9, as well as 2 and 4, have the same parity, while 6 and 9 do not. … Read more

3222. Find the Winning Player in Coin Game using JavaScript

0 Problem You are given two positive integers x and y, denoting the number of coins with values 75 and 10 respectively. Alice and Bob are playing a game. Each turn, starting with Alice, the player must pick up coins with a total value 115. If the player is unable to do so, they lose the game. Return the name of the player who wins the game if … Read more

3226. Number of Bit Changes to Make Two Integers Equal using JavaScript

0 Problem You are given two positive integers n and k. You can choose any bit in the binary representation of n that is equal to 1 and change it to 0. Return the number of changes needed to make n equal to k. If it is impossible, return -1. Example 1: Input: n = 13, k = 4 Output: 2 Explanation:Initially, the binary representations of n and k are n = (1101)2 and k = (0100)2.We can … Read more

Skip to content