• LeetCode每日一题(2306. Naming a Company)


    You are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company is as follows:

    Choose 2 distinct names from ideas, call them ideaA and ideaB.
    Swap the first letters of ideaA and ideaB with each other.
    If both of the new names are not found in the original ideas, then the name ideaA ideaB (the concatenation of ideaA and ideaB, separated by a space) is a valid company name.
    Otherwise, it is not a valid name.
    Return the number of distinct valid names for the company.

    Example 1:

    Input: ideas = [“coffee”,“donuts”,“time”,“toffee”]
    Output: 6

    Explanation: The following selections are valid:

    • (“coffee”, “donuts”): The company name created is “doffee conuts”.
    • (“donuts”, “coffee”): The company name created is “conuts doffee”.
    • (“donuts”, “time”): The company name created is “tonuts dime”.
    • (“donuts”, “toffee”): The company name created is “tonuts doffee”.
    • (“time”, “donuts”): The company name created is “dime tonuts”.
    • (“toffee”, “donuts”): The company name created is “doffee tonuts”.
      Therefore, there are a total of 6 distinct company names.

    The following are some examples of invalid selections:

    • (“coffee”, “time”): The name “toffee” formed after swapping already exists in the original array.
    • (“time”, “toffee”): Both names are still the same after swapping and exist in the original array.
    • (“coffee”, “toffee”): Both names formed after swapping already exist in the original array.

    Example 2:

    Input: ideas = [“lack”,“back”]
    Output: 0

    Explanation: There are no valid selections. Therefore, 0 is retu

  • 相关阅读:
    专业的ADAS测试记录仪ETHOS
    简易实现Spring Framework底层机制
    Macos数据库管理:Navicat Premium 中文
    人工智能、深度学习、机器学习常见面试题221~240
    奇妙的函数【JavaScript】
    谈一个谈这几个月的收获
    uniapp subNvue 写的视频播放
    JDK中字符的宽度计算流程
    Spread 16.X FOR WPF 中文版 我就喜欢 Spread.NET
    全志 Android 11:实现响应全局按键
  • 原文地址:https://blog.csdn.net/wangjun861205/article/details/127901421