801B - Valued Keys - CodeForces Solution


constructive algorithms greedy strings *900

Please click on ads to support us..

Python Code:

x = input()
y = input()

z = ""

for i, l in enumerate(y):
    if l > x[i]:
        z = "-1"
        break
    elif l <= x[i]:
        z += l

print(z)

C++ Code:

#include <bits/stdc++.h>

using namespace std;

int main() {
    string x, y;
    cin >> x >> y;

    int check = 1;
    for (int i = 0 ; i < x.size() ; i++)
        check &= (x[i] >= y[i]);

    if (check)
        cout << y << endl;
    else
        cout << -1 << endl;

    return 0; 
}


Comments

Submit
0 Comments
More Questions

630I - Parking Lot
160B - Unlucky Ticket
371B - Fox Dividing Cheese
584B - Kolya and Tanya
137B - Permutation
550C - Divisibility by Eight
5A - Chat Servers Outgoing Traffic
615A - Bulbs
5B - Center Alignment
549A - Face Detection
535B - Tavas and SaDDas
722C - Destroying Array
366A - Dima and Guards
716B - Complete the Word
1461C - Random Events
1627A - Not Shading
141B - Hopscotch
47B - Coins
1466C - Canine poetry
74A - Room Leader
1333D - Challenges in school №41
1475B - New Year's Number
461A - Appleman and Toastman
320B - Ping-Pong (Easy Version)
948A - Protect Sheep
387A - George and Sleep
53A - Autocomplete
1729G - Cut Substrings
805B - 3-palindrome
805C - Find Amir