All Posts
Leetcode 2606: Find the Substring With Maximum Cost
You are given a string s, a string chars of distinct characters, and an integer array vals of the same length as chars. The value of each character is determined by either its position in the alphabet or a corresponding value in the vals array if it is present in chars. The cost of a substring is the sum of the values of each character in that substring. Your goal is to find the maximum cost of any substring of s.
Leetcode 2610: Convert an Array Into a 2D Array With Conditions
Given an integer array, your task is to create a 2D array from the input array satisfying the following conditions:
- The 2D array should contain all the elements of the input array.
- Each row of the 2D array should contain distinct integers.
- The number of rows in the 2D array should be minimal. Return the resulting array. If there are multiple valid answers, return any of them.