Posts

Showing posts from January, 2022

First Missing Positive

  Problem Statement Suggest Edit You are given an array 'ARR' of integers of length N. Your task is to find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can have negative numbers as well. For example, the input [3, 4, -1, 1] should give output 2 because it is the smallest positive number that is missing in the input array. Input Format: The first line of input contains a single integer T, representing the number of test cases or queries to be run. Then the T test cases follow. The first line of each test case contains a positive integer N which represents the length of the array. The second line of each test case contains N integers representing the elements of the array 'ARR'. Output Format : For each test case, print a single integer denoting the minimum positive integer that is missing from the given input array. Th output of each test case will b...

Read from STDIN, Write to STDOUT

Problem Read different types of data from standard input, process them as shown in output format and print the answer to standard output. Input format: First line contains integer N. Second line contains string S. Output format: First line should contain N x 2. Second line should contain the same string S. Constraints: 0 ≤ N ≤ 10 1 ≤ | S | ≤ 15  where  S  length of string  S  Sample Input 5 helloworld Sample Output 10 helloworld Time Limit: 1 Memory Limit: 256 Source Limit: /* // Sample code to perform I/O: name = Console.ReadLine(); // Reading input from STDIN Console.WriteLine("Hi, {0}.", name); // Writing output to STDOUT // Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail */ // Write your code here using System ; namespace practice { class Program { static void Main ( string [] args ) { int a = Convert . ToInt32 ( Console . ReadLine ()); ...

C# Basics ii

 /////////////// player.cs /////////////////// using System; using System.Collections.Generic; using System.Text; namespace beginner_2 {     class Player     {         public string name = "sayan";         private int health = 49;         public int gethealth()         {             return health;         }         public void sethealth(int h)         {             health = h;         }     } } /////////////// main.cs /////////////////////// using System; namespace beginner_2 {     class Program     {         const int a = 9; // Global var          static void Greet()  // Greet belongs to the class Program , not returning value         {   ...

C# Basics

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Hello {     class Program     {         static void Main(string[] args)         {             int har = 34;             /*                                           Data Types of c#:              integer - int va -> 4 Bytes ;             Long - long var -> 8 Bytes ;             Double - double var -> 8 Bytes ;              floating - float var -> 4 Bytes;             char var = 'A' -> 2 Bytes;             bool var = true / false  -...

Turtle

import  ColabTurtle.Turtle  as  timmy timmy.initializeTurtle ( initial_speed= 5 ) def  dashed() :   timmy.forward ( 10 )   timmy.penup ()   timmy.forward ( 10 )   timmy.pendown () def  intializer() :   timmy.initializeTurtle ()       timmy.color ( '#00BFFF' )   # draw all regular shapes with [3:10] sides import  random colours =  [ '#0000FF' , '#ADFF2F' , '#C71585' , '#00FF7F' , '#00FFFF' , '#FF69B4' , '#00BFFF' ] intializer () for  n  in  range ( 3 , 11 ):   timmy.color ( random.choice ( colours ))   total =  180  * ( n -  2 )   sides = n       for  _  in  range ( sides ):               timmy.right ( 180  - total/sides )     timmy.forward ( 100 )

Online Questionere

https://opentdb.com/api.php?amount=10&category=11&difficulty=easy&type=boolean question_data= [      {          'category' :   'Entertainment: Film' ,          'type' :   'boolean' ,          'difficulty' :   'easy' ,          'question' :   'Han Solo's co-pilot and best friend, "Chewbacca", is an Ewok.'              ,          'correct_answer' :   'False' ,          'incorrect_answers' :   [ 'True' ],          },      {          'category' :   'Enterta...