In this article, we will discuss how to generate a random password of a given length consists of any characters.
- The below-given program involves basic concepts like variables, data types, array, loop, etc.
- Follow the below steps to solve this problem:
- Take the length of the password and declare a character array of that length to store that password.
- Declare character array of all the capital letters, small letters, numbers, special characters.
- Now according to the program below, respective if-else gets executed and a random password gets generated.
Below is the program of the above approach:
Time Complexity: O(N)
Auxiliary Space: O(26)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.