ChatGPT brush force buckle interview question 01.02. Determine whether each other is a character rearrangement

topic description

Given two strings s1 and s2 of lowercase letters, write a program to determine if the characters of one string can be rearranged to make the other string.

Example 1:

Input: s1 = "abc", s2 = "bca"

output: true

Example 2:

Input: s1 = "abc", s2 = "bad"

output: false

illustrate:

0 <= len(s1) <= 100

0 <= len(s2) <= 100

Source: LeetCode

Link: https://leetcode.cn/problems/check-permutation-lcci

The copyright belongs to Lingkou Network. For commercial reprints, please contact the official authorization, for non-commercial reprints, please indicate the source.

Start solving problems (python)

Check step by step

1. Positive test cases

2. Negative test cases

absorb learning

Refer to the example of Likou and throw it to GPT to optimize the code:

Experts are among the people (one line of code to solve algorithm problems)

By the way, learn to understand the following python's sorted function

Guess you like

Origin blog.csdn.net/qq_39154376/article/details/131830303