• Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
CODE OF GEEKS

We at CODE OF GEEKS, aim at providing best and quality content for our users at no extra cost.

    • Study Materials – Company wise
      • Infosys Archive
      • Accenture Archive
      • AMCAT Archive
      • Capgemini Archive
      • Cisco Archive
      • CoCubes Archive
      • Cognizant(CTS) Archive
      • Dell Archive
      • Deloitte Archive
      • DXC Archive
      • Goldman Sachs Archive
      • Hexaware Technologies Archive
      • LTI Archive
      • MindTree Archive
      • TCS Archive
      • Virtusa Archive
      • Wipro Archive
    • Interview Preparation – E Books
      • C Interview Questions
      • Data Structures Interview Questions
      • DBMS Interview Questions
      • HR Interview Questions
      • Java Interview Questions
      • Operating System Interview Questions
      • Python Interview Questions
      • SQL Query Interview Questions
    • Programming
      • C Programming MCQs
      • C Code Snippets – Output Questions
      • Python Code Snippets – Output Questions
    • Aptitude
      • Verbal Ability for Placements
      • Quant for Placements
    • Register
    • Login
  • [email protected]
  • ..
Login / Register
Apply Now
CODE OF GEEKS
CODE OF GEEKS
  • Study Materials – Company wise
    • Infosys Archive
    • Accenture Archive
    • AMCAT Archive
    • Capgemini Archive
    • Cisco Archive
    • CoCubes Archive
    • Cognizant(CTS) Archive
    • Dell Archive
    • Deloitte Archive
    • DXC Archive
    • Goldman Sachs Archive
    • Hexaware Technologies Archive
    • LTI Archive
    • MindTree Archive
    • TCS Archive
    • Virtusa Archive
    • Wipro Archive
  • Interview Preparation – E Books
    • C Interview Questions
    • Data Structures Interview Questions
    • DBMS Interview Questions
    • HR Interview Questions
    • Java Interview Questions
    • Operating System Interview Questions
    • Python Interview Questions
    • SQL Query Interview Questions
  • Programming
    • C Programming MCQs
    • C Code Snippets – Output Questions
    • Python Code Snippets – Output Questions
  • Aptitude
    • Verbal Ability for Placements
    • Quant for Placements
  • Register
  • Login
0

Cart

4 Digit OTP

  • January 6, 2020
  • CODE OF GEEKS
  • 2


You will be given a number in the form of string, extract out digits at odd places, square & merge them. First 4 digits will be the required OTP.

Input : 

First Input : String

Output : 4 digit OTP

Sample Testcases :

I/P 1:

34567

O/P 1:

1636



Solution : 

n=input()
s=””
i=0
for i in range(0,len(n)):
    if int(i)%2==1:
        s+=str(int(n[i])**2)
print(s[:4]) 


Tags: infosys last year handson problemsinfytqinfytq examinfytq examinationinfytq handson problems last yearinfytq handson problems of last yearinfytq handson questionsinfytq last year coding problemsinfytq last year problemsinfytq last year questionsLast year questions Infytqpractice infyprepare infytq question
  • Previous Arithmetic Expression
  • Next Special Reversal

2 comments on “4 Digit OTP”

  1. Maddu Prathibha says:
    March 5, 2020 at 12:17 pm

    If possible please provide more tricky test cases (hidden) so that the we will increase our learning scope without limiting our capability of coding only for a sample test case.

    Reply
  2. Charan Manne says:
    June 13, 2020 at 9:56 am

    import java.util.*;
    import java.io.*;
    public class OTP {
    public static void main(String[] args) throws Exception{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    String s=br.readLine();String s1=””;
    for(int i=1;i<s.length();i=i+2){
    s1+=Integer.parseInt(""+s.charAt(i))*Integer.parseInt(""+s.charAt(i));
    }
    System.out.println(s1.substring(0,4));
    }
    }

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CODE OF GEEKS

Subscribe to Newsletter

CODE OF GEEKS

Learn | Code | Achieve

Reach us

[email protected]
We at CODE OF GEEKS, aim at providing quality content to our users at no cost.
CODE OF GEEKS

Important Pages

About us
Advertise
Privacy Policy
Terms and Conditions

Placements – Study Materials

TCS NQT     Wipro     CapGemini
Accenture     MindTree     CTS
DXC     Hexaware Technologies     AMCAT
CoCubes     Goldman Sachs     Dell
Cisco     Deloitte     Virtusa     LTI     Infosys   

Courses

  • Mail Us
  • Login/Register

Recent Posts

What is Cloud Computing | Cloud Computing Applications | Cloud Development Models| SaaS vs PaaS vs IaaS
  • October 23, 2021
What is Amazon Web Services | AWS Regions & AZs | Different AWS Services
  • October 19, 2021

Copyright 2021 CODE OF GEEKS. All Rights Reserved.

  • →