Posts

Showing posts from March, 2022

Chomsky's hierarchy Explanation :

Image
                      Chomsky's hierarchy  Explanation  and its types : Connect with me on According to Chomsky, there are 4 types of Finite language. T0,T1,T2,T3. Chomsky's hierarchy  Diagram: T0 is superset of T1,T2,T3. T1 IS SUPERSET OF T2,T3. T2 IS SUPERSET OF T3. connect with me on A Topic from Theory of Computation (TOC) Chomsky's hierarchy Explanation Table: Language type Accepted Language Accepting machine T3 REGULAR LANGUAGE FINITE AUTOMATA T2 CONTEXT FREE LANGUAGE (CFL) PUSH DOWN AUTOMATA (PDA) T1 CONTEXT SENSETIVE LANGUAGE (CSL) LINEAR BOUND AUTOMATA (LBA) T0 RECURSSIVE ENUMERABLE LANGUAGE (REL) TURING MACHINE Knowledgable Tip : For a Computer science aspirant A award is given to t

EV_First Unique Character asked in Infosys march 2022 on hackerrank platform

Image
                                                  EV_First Unique Character connect with me on Facebook Twitter Instagram Github Youtube                                                  3. EV_First Unique Character A unique character is one that appears only once in a string. Given a string consisting of lowercase English letters only, return the index of the first occurrence of a unique character in the string using 1-based indexing. If the string does not contain any unique character, return-1. Example s="statistics" The unique characters are [a, c] among which a occurs first. Using 1-based indexing, it is at index 3. Function Description Complete the function getUnique Character in the editor below. getUniqueCharacter has the following parameter(s): string s: a string Returns int: either the 1-based index or -1 Constraints • 1 s. length of ss 105 . The string s consists of lower

EV Minimize Array Cost asked in Infosys- march 2022 (available in c++ only)

                                                             EV_Minimize Array Cost connect with me on Facebook Twitter Instagram Github Youtube len(arr)-1 Σ(arri-arri-1)² i=1 len(arr) is the size of the array. Insert any integer at any location of the array such that the cost of the array is minimized. Find the minimum possible cost of the array after inserting exactly one element. Example a= [1, 3, 5, 2, 10] The cost of the array before insertion =(1-37+(3-57+(5-2)²+(2-102²= 81. Two of many scenarios are shown below. 1. Insert 4 between 3 and 5, cost of array = (1-37+(3-47+(4-57+(5-2)²+(2 107²2² = 79. 2. Insert 6 between 2 and 10, cost of array =(1-37+(3-5)+(5-27²+(2-67² + (6 107² = 49. It can be proven that 49 is the minimum cost possible. Return 49. Function Description Complete the function getMinimumCost in the editor below. mumest fas the following parameter arrfet an array of ietsge

Nick's Check

Image
                                                  NICK'S CHECK .......................................................................................................................................................................... connect with me on Facebook Twitter Instagram Github Youtube ................................................................................................................................................................ connect with me on Facebook Twitter Instagram Github Youtube

Sum of largest and smallest element in array by tech mahindra 2022

Image
 Sum of the largest and smallest element in the array by tech Mahindra 2022.. .......................................................................................................................................................................... connect with me on Facebook Twitter Instagram Github Youtube ............................................................................................................................................ connect with me on Facebook Twitter Instagram Github Youtube

Second largest element in an array

Image
Given an array (containing at most 1000 positive integers), find the second largest integer. If there exists no second largest integer, return-1,  Input Specification:   input1 : length of the array input2: an array of positive integers  Output Specification:  Return the second largest number or-1 accordingly Example 1: input1: 3 input2: (2,1,2).. .......................................................................................................................................................................... connect with me on Facebook Twitter Instagram Github Youtube   ...................................................................................................................................................... connect with me on Facebook Twitter Instagram Github Youtub

Program to reverse the position of words

Image
 Program to reverse the position of words in a given spaced string. example :  input: my name is ayush output: ayush is my name input: you go there i will here output : here will i there go you .......................................................................................................................................................................... .................................................................................................................................................................... connect with me on Facebook Twitter Instagram Github Youtube

Number of trailing zeros in factorial asked in tech mahindra 2022

Image
                        Number of trailing zeros in factorial of a number asked in tech Mahindra 2022 .........................................................................................................................................................................

Sum of digits of factrorial of a given number asked in zensar march 2022

Image
                                                              Sum of digits of factorial .................................................................................................................................................................. connect with me on Facebook Twitter Instagram Github Youtube connect with me on Facebook Twitter Instagram Github Youtube

Transmit data in encrypted way (digit + 7) mod 10 asked in ZENSAR 2022 march

Image
 A company wants to transmit data over the telephone line, but they are concemed that their lives are tapped All of their data is transmitted as four-digit integers. They decided to encrypt a four digit number as follows  1: They will replace each digit by (digit+7) mad 10).  2: They will then swap the first digit with the third digit and the second digit with the foun The resulting four-digit number is then encrypted number  Write a program that can do an encryption operation. The program must take one input.  The input is a positive integer depending on the input.  Codes are in two methods  1 . without using function 2. Using a function and returning an array connect with me on Facebook Twitter Instagram Github Youtube 1st Method :- *********************************************************** 2. Using a function which retins an array  connect with m

Remove duplicate characters from a string tech mahindra 2022

Image
                                                             Remove duplicate characters Return a string with non-duplicate characters, ie, if you have a string as metti then output should be mett, keeping the order of characters same. Example 1: Input1: Csharpstarz Output: Csharptz Explanation: On removing duplicate elements from the orignal string Csharpstarz, we Csharptz....... connect with me on Facebook Twitter Instagram Github Youtube   connect with me on Facebook Twitter Instagram Github Youtube

Adams charity tech mahindra 2022

Image
 Adams decided to be generous and do some charity. Starting today from day 1 until n days he decided to donate i^2 coins to charity. Return total coins he donated. connect with me on Facebook Twitter Instagram Github Youtube connect with me on Facebook Twitter Instagram Github Youtube

LCM code tech mahindra 2022

Image
                                                                                LCM CODE ************************************************************************************ connect with me on Facebook Twitter Instagram Github Youtube

Palindrome code tech mahindra march 2022

Image
                                                                     TECH MAHINDRA CODE Palindrome code tech Mahindra march 2022 connect with me on Facebook Twitter Instagram Github Youtube connect with me on Facebook Twitter Instagram Github Youtube