Easy-16

本文解析了LeetCode 521题——寻找两个字符串中最长的非公共子序列的问题。通过简单的字符串比较而非复杂的动态规划解决了该问题,并提供了一个直观的C语言实现示例。

leetcode      521. Longest Uncommon Subsequence I      

Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other strings.

A subsequence is a sequence that can be derived from one sequence by deleting some characters without changing the order of the remaining elements. Trivially, any string is a subsequence of itself and an empty string is a subsequence of any string.

The input will be two strings, and the output needs to be the length of the longest uncommon subsequence. If the longest uncommon subsequence doesn't exist, return -1.

Example 1:

Input: "aba", "cdc"
Output: 3
Explanation: The longest uncommon subsequence is "aba" (or "cdc"), 
because "aba" is a subsequence of "aba", 
but not a subsequence of any other strings in the group of two strings. 

Note:

  1. Both strings' lengths will not exceed 100.
  2. Only letters from a ~ z will appear in input strings.

    

AC:

int findLUSlength(char* a, char* b) {
    int len1=strlen(a);
    int len2=strlen(b);
    if(len1!=len2)
    {
        return len1>len2?len1:len2;
    }
    if(strstr(a,b)==NULL)
    {
        return len1;
    }else
    {
       
        return -1;
    }
}

tip:最开始看标题,以为是动态规划类的题目,后来发现这个题目有点nc。。。搞笑的吧。。。

### 创建简易HTML播放器的方法 要创建一个简单的HTML播放器,可以利用HTML5中的`<audio>`或`<video>`标签来实现基本功能。以下是通过HTML和JavaScript构建的一个简单音频播放器的示例: #### 基本结构 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Simple Audio Player</title> <style> .player { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 20px; } button { padding: 10px; font-size: 16px; } </style> </head> <body> <h1>简易HTML音频播放器</h1> <div class="player"> <button id="playButton">播放</button> <button id="pauseButton">暂停</button> <audio id="audioPlayer" src="example.mp3"></audio> </div> <script> const audio = document.getElementById('audioPlayer'); const playButton = document.getElementById('playButton'); const pauseButton = document.getElementById('pauseButton'); playButton.addEventListener('click', () => { audio.play(); }); pauseButton.addEventListener('click', () => { audio.pause(); }); </script> </body> </html> ``` 上述代码展示了如何使用HTML `<audio>` 标签以及JavaScript控制其播放和暂停的功能[^3]。 #### 关键特性说明 1. **HTML `<audio>` 或 `<video>` 标签** 这些标签允许嵌入多媒体文件到网页中,并提供内置控件(如果启用 `controls` 属性)。例如: ```html <audio controls> <source src="example.mp3" type="audio/mpeg"> 浏览器不支持此音频格式。 </audio> ``` 2. **自定义按钮与事件监听** 使用JavaScript绑定点击事件至播放/暂停按钮上,从而增强用户体验并隐藏默认控件。 3. **样式调整** 利用CSS美化界面布局,使播放器更直观易用。 #### 扩展功能建议 为了进一步提升播放器的功能性和交互体验,可考虑加入以下改进措施: - 添加音量调节滑块。 - 显示当前播放时间及总时长。 - 支持多个媒体资源切换。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值