首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
去除重复字母
[编程题]去除重复字母
热度指数:1524
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
给定一个字符串 s ,请你去除字符串中重复的字母(剩下的字符串中每个字符仅出现一次),并在不改变其相对位置的情况下使剩下的字符串字典序最小。
数据范围:字符串长度满足
, 字符串中仅出现小写英文字母
示例1
输入
"abcd"
输出
"abcd"
示例2
输入
"acbcd"
输出
"abcd"
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(31)
分享
纠错
提交结果有问题?
5个回答
8篇题解
开通博客
姐姐的遮阳伞
发表于 2022-04-08 18:34:11
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @
展开全文
太阳hxy
发表于 2023-09-01 14:32:21
class Solution { public: string removeDuplicateLetters(string str) { int n=str.size(); //创建两个容器 //hash用来存字符串中每个字母最后一次出现的
展开全文
牛客马克西
发表于 2023-10-19 17:13:50
注意区别:题解30 | 连续重复的东西总会被消除#点击消除#https://www.nowcoder.com/discuss/536957728435064832 #include <iterator> #include <vector> class Solution {
展开全文
17c89
发表于 2024-09-22 20:23:23
import java.util.*; /** * NC375 去除重复字母 * @author d3y1 */ public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * *
展开全文
kboyMeng
发表于 2023-07-08 14:59:30
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ function removeDuplicateLetters( str ) { // w
展开全文
huowolf
发表于 2023-01-03 23:53:47
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @ret
展开全文
17c89
发表于 2024-06-03 19:14:45
import java.util.*; /** * NC375 去除重复字母 * @author d3y1 */ public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * *
展开全文
觉醒火龙果很想五点下课
发表于 2025-05-16 18:56:24
#include <stack> #include <string> class Solution { public: string removeDuplicateLetters(string str) { int n = str.size();
展开全文
问题信息
贪心
字符串
栈
单调栈
难度:
5条回答
31收藏
5925浏览
热门推荐
通过挑战的用户
查看代码
半个西瓜半个夏
2022-09-16 10:08:05
牛客52071...
2022-09-14 21:28:39
xzd-698
2022-09-10 23:12:59
林子20190...
2022-09-05 11:41:51
。。20190...
2022-09-05 01:05:04
相关试题
求序列里最长的非降序列 例如:输...
百度
贪心
评论
(12)
下面使用贪心算法的是?
阿里巴巴
贪心
评论
(1)
3.下列关于表中西部省市区2006...
资料分析
言语理解与表达
资料分析
评论
(1)
Mysql中表student_in...
数据库
SQL
评论
(1)
SQL中,下列涉及空值的操作不正确...
SQL
评论
(0)
去除重复字母
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ public String removeDuplicateLetters (String str) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ string removeDuplicateLetters(string str) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param str string字符串 # @return string字符串 # class Solution: def removeDuplicateLetters(self , str ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ public string removeDuplicateLetters (string str) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ function removeDuplicateLetters( str ) { // write code here } module.exports = { removeDuplicateLetters : removeDuplicateLetters };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param str string字符串 # @return string字符串 # class Solution: def removeDuplicateLetters(self , str: str) -> str: # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ func removeDuplicateLetters( str string ) string { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ char* removeDuplicateLetters(char* str ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param str string字符串 # @return string字符串 # class Solution def removeDuplicateLetters(str) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ def removeDuplicateLetters(str: String): String = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ fun removeDuplicateLetters(str: String): String { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ public String removeDuplicateLetters (String str) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ export function removeDuplicateLetters(str: string): string { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ func removeDuplicateLetters ( _ str: String) -> String { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param str string字符串 * @return string字符串 */ pub fn removeDuplicateLetters(&self, str: String) -> String { // write code here } }
"abcd"
"abcd"
"acbcd"
"abcd"