Showing 9 questions
You're given a graph; your goal is to add edges to it so that every node has an even degree. Find the minimum number of edges to add to achieve this.
#1. Add Edges to Make Degrees of All Nodes Even
Find the longest path in a tree where no two adjacent nodes on the path have the same character. The tree is defined by parent-child relationships and each node has an associated character.
#2. Longest Path With Different Adjacent Characters
You are given a grid of numbers. Find the maximum possible score by traversing the grid, starting from the top-left cell and ending at the bottom-right cell, following specific movement rules.
#3. Maximum Score From Grid Operations
Determine if a pattern of a certain length repeats itself consecutively in an array at least a given number of times. Specifically, check for repeating subarrays.
#4. Detect Pattern of Length M Repeated K or More Times
Determine the number of steps required to reduce a non-negative integer to zero. You can either divide by 2 if the number is even, or subtract 1 if it's odd.
#5. Number of Steps to Reduce a Number to Zero
You're given a number containing only digits 6 and 9. Find the maximum possible number you can get by changing at most one digit (6 to 9 or 9 to 6).
#6. Maximum 69 Number
You are given a graph representing cities and roads. Assign each city a value such that the total importance of all roads (sum of the values of the cities connected by each road) is maximized.
#7. Maximum Total Importance of Roads
Given an integer, you need to express it as the sum of two positive integers, neither of which contains the digit zero. Find and return any such pair of no-zero integers.
#8. Convert Integer to the Sum of Two No-Zero Integers
Given source code as a string, remove all comments. Handle both single-line (//) and multi-line (/* */) comments, ensuring correct nesting.
#9. Remove Comments