Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to determine if the string has all unique characters using C#?
To determine if a string has unique characters or not, firstly check a word in the string with the next word −
for (int j = i + 1; j < val.Length; j++) {
if (val[i] == val[j])
}
If you find a match, that would mean the string do not have unique characters.
If you are unable to find a match, then the string has all unique characters.
In case of a match, return false i.e. unique characters not found −
for (int j = i + 1; j < val.Length; j++) {
if (val[i] == val[j])
return false;
} Advertisements
