filmov
tv
L-28 | 2976. Minimum Cost to Convert String I | graphs | shortest path | Leetcode | DSA | Java

Показать описание
Problem Name:
2976. Minimum Cost to Convert String I
Problem Statement:
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character arrays original and changed, and an integer array cost, where cost[i] represents the cost of changing the character original[i] to the character changed[i].
You start with the string source. In one operation, you can pick a character x from the string and change it to the character y at a cost of z if there exists any index j such that cost[j] == z, original[j] == x, and changed[j] == y.
Return the minimum cost to convert the string source to the string target using any number of operations. If it is impossible to convert source to target, return -1.
Note that there may exist indices i, j such that original[j] == original[i] and changed[j] == changed[i].
Problem Link:
Solution Link:
Graph Playlist:
Java Plus DSA Placement Course Playlist:
Java Plus DSA Sheet:
Notes:
Telegram Link:
Ultimate Recursion Series Playlist:
Samsung Interview Experience:
Company Tags:
Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung
Timestamp:
0:00 - Introduction
#ShashwatTiwari #coding #problemsolving
2976. Minimum Cost to Convert String I
Problem Statement:
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character arrays original and changed, and an integer array cost, where cost[i] represents the cost of changing the character original[i] to the character changed[i].
You start with the string source. In one operation, you can pick a character x from the string and change it to the character y at a cost of z if there exists any index j such that cost[j] == z, original[j] == x, and changed[j] == y.
Return the minimum cost to convert the string source to the string target using any number of operations. If it is impossible to convert source to target, return -1.
Note that there may exist indices i, j such that original[j] == original[i] and changed[j] == changed[i].
Problem Link:
Solution Link:
Graph Playlist:
Java Plus DSA Placement Course Playlist:
Java Plus DSA Sheet:
Notes:
Telegram Link:
Ultimate Recursion Series Playlist:
Samsung Interview Experience:
Company Tags:
Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung
Timestamp:
0:00 - Introduction
#ShashwatTiwari #coding #problemsolving
Комментарии