
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
A unique string in Python
Suppose we have a string s, we have to check whether it has all unique characters or not.
So, if the input is like "world", then the output will be True
To solve this, we will follow these steps −
set_var := a new set from all characters of s
return true when size of set_var is same as size of s, otherwise false
Let us see the following implementation to get better understanding −
Example
class Solution: def solve(self, s): set_var = set(s) return len(set_var) == len(s) ob = Solution() print(ob.solve('hello')) print(ob.solve('world'))
Input
hello world
Output
False True
- Related Questions & Answers
- First Unique Character in a String in Python
- Check if an encoding represents a unique binary string in Python
- Python program to check if a string contains all unique characters
- Python program to check if a string contains any unique character
- Find the longest substring with k unique characters in a given string in Python
- Unique Paths in Python
- Number of non-unique characters in a string in JavaScript
- Unique Substrings in Wraparound String in C++
- Unique substrings in circular string in JavaScript
- How to find a unique character in a string using java?
- Creating all possible unique permutations of a string in JavaScript
- Generating a unique random 10 character string using MySQL?
- Program to find split a string into the max number of unique substrings in Python
- Get unique values from a list in Python
- Program to find length of concatenated string of unique characters in Python?
Advertisements