Skip to content
Onsite

Ash and His Redemption

EasyP3Coding

Ash and Gary each have n pokemon, and n rounds are played: in round i Gary's pokemon gary[i] fights one of Ash's pokemon. Ash wins a round only if his pokemon's HP is strictly greater than Gary's. Ash wins the match if he wins every round. Gary's lineup is fixed; Ash may assign his pokemon to the rounds in any order, using each exactly once.

Return true if Ash can win the match, otherwise false. (The original problem prints "Ash Finally Wins" or "Train Hard Again"; here you return a boolean.)

Example 1

Input
ash = [5,6,7], gary = [4,5,6]
Output
true

Example 2

Input
ash = [5,5], gary = [4,5]
Output
false
Why
One of Ash's pokemon would face Gary's pokemon of HP 5 with only HP 5.

Constraints

  • 1 <= n <= 10^5
  • ash.length == gary.length == n
  • 1 <= HP <= 10^9

Hints

Run checks the 3 visible tests, Submit all 10.