Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
23,168 views
in Service-based-companies by Expert (107,890 points)
edited by | 23,168 views

2 Answers

0 like 0 dislike
Best answer

All questions can be found here : https://www.desiqna.in/769/upgrade-ninja-offer-digital-information-sample-questions?show=769#q769 

Solution 1 

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() 
{

    
    ll n ; 
    cin>>n ; 
    vector <ll> a ; 
    ll i = 0 ;
    while(i<n)
    {
        ll x ; 
        cin>>x;
        a.push_back(x); i++;
    }
    ll k ; 
    cin>>k ; 
    sort(a.begin(),a.end());
    cout<<a[k-1];

    return 0;
    
}

Solution 2 

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() 
{

    
    ll n ; 
    cin>>n ; 
    if(n<0)
    {
        cout<<"Wrong Input";
    }
    else
    {
        ll bad = 0 ;
        ll g = n*n ; 
        string s1 = to_string(n);
        string s2 = to_string(g);
        ll o = s1.size();
        ll i1 = o-1;
        ll j1 = s2.size();
        j1--;
        while(i1>=0)
        {
            if(s1[i1]==s2[j1])
            {
                
            }
            else
            {
                bad = 1;
            }
            j1--;
            i1--;
            
        }
        
        if(bad==0)
        {
            cout<<"Correct Number";
        }
        else
        {
            cout<<"Incorrect Number";
        }
    }

    return 0;
    
}

Solution 3 : 

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() 
{

    string s ; 
    cin>>s;
    ll g = int(s[0]);
    if(g>=97 && g<=122)
    {
        cout<<"lower alphabet";
    }
    else if(g>=65 && g<=90)
    {
        cout<<"UPPER ALPHABET";
    }
    else if(g>=48 && g<=57)
    {
        cout<<"Number";
    }
    else
    {
        cout<<"Symbol";
    }

    return 0;
    
}

 

 

 

by Expert (107,890 points)
0 0
Solution 1 in java:-

import java.util.*;
public class NthSmallestElement {

    public static void main(String[] args) {
        List<Integer> nums = new ArrayList<Integer>();
        Scanner scan = new Scanner(System.in);
        int size = scan.nextInt(); //number of inputs
       
        for(int i=0; i<size; i++) {
            int element = scan.nextInt();
            nums.add(element);
        }
       
        int lowestPosition = scan.nextInt(); //nth position
        scan.close();
       
        Collections.sort(nums);
        System.out.println(nums.get(lowestPosition-1));

    }

}
0 0
Solution 2 in Java:-

import java.util.Scanner;

public class NumberEndsWith {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        scan.close();
        int square = num*num;
       
        String numString = Integer.toString(num);
        String squareString = Integer.toString(square);
       
        if(squareString.endsWith(numString)) {
            System.out.println("Correct Number");
        } else {
            System.out.println("Invalid Number");
        }

    }

}
0 0
Solution 3 in Java:-

import java.util.*;
public class DetermineType {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("Enter a Character/Digit/Symbol");
        char ch = scan.next().charAt(0);
        scan.close();
       
        if(ch >= 'A' && ch <= 'Z') {
            System.out.println(ch + " is an uppercase character");
        } else if (ch >= 'a' && ch <= 'z') {
            System.out.println(ch + " is a lowercase character");
        } else if (Character.isDigit(ch)) {
            System.out.println(ch + " is a digit");
        } else {
            System.out.println(ch + " is a symbol");
        }

    }

}
0 like 0 dislike
list1=[]
n= int(input())
for i in range(0,n):
    ele = int(input())
    list1.append(ele)
g=int(input())
list1.sort()
print(list1[g-1])
print(list1)
by