# SPIT3-Editorial

Practice

Contest

Author: Vikesh Tiwari

Tester : Vikesh Tiwari

Editorialist: Vikesh Tiwari

CakeWalk

implementation

## PROBLEM

Given string as a password. Check if it satisfies following conditions.

• Length is at least 5 characters.
• At least one Large English letter.
• At least one small English letter.
• It should contain at least one digit.

If String Satifies all the Conditions, print “YES” else print “NO”.

## EXPLANATION

Problem is Straight forward. Just correctly implement what was written in statement.

# C++ Code:

``````#include<iostream>
#include<set>
using namespace std;
string s;
cin >> s;
bool upper = false, lower = false, digit = false;
for(int i= 0; i < s.size(); ++i){
if(isupper(s[i]))
upper = true;
if(islower(s[i]))
lower = true;
if(isdigit(s[i]))
digit = true;
}
puts((upper && lower && digit && s.size() >= 5) ? "YES" : "NO");
``````

## COMPLEXITY:

O(N)

Sir please tell what is wrong in my implementation here?

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char s[50];
scanf("%s",s);
int upper = 0, lower = 0, digit = 0,i;
for(i= 0; i < sizeof(s)-1; ++i)
{
if(isupper(s[i]))
upper = 1;
if(islower(s[i]))
lower = 1;
if(isdigit(s[i]))
digit = 1;
}
if(upper==1&&lower==1&&digit==1&&sizeof(s)>=5)
{