Infosys 24th April All Slots Answers LIVE Updates in 5 Seconds Keep Refreshing
1)Python 3
Special number after aurgument Code
8)A lot of sum Code Python
3)Array
Java
- import java.util.Arrays;
- public class GFG {
- public static void main(String[] args) {
- int max = 1000000;
- int[] facs = new int[max];
- for (int i = 2; i < max; ++i) {
- for (int j = i; j < max; j += i) {
- facs[j]++;
- }
- }
- // System.out.println(Arrays.toString(facs));
- int count = 0;
- for (int i = 0; i < max; ++i)
- if (facs[i] == 7)// 1 is a factor of all number so check for count 7
- {
- if (primeFactors(i) == 2 + 1) {
- System.out.println("YESSSSSSS");
- break;
- }
- }
- System.out.println(count);
- }
- static int primeFactors(int n) {
- // Print the number of 2s that divide n
- while (n % 2 == 0) {
- n /= 2;
- }
- // n must be odd at this point. So we can
- // skip one element (Note i = i +2)
- for (int i = 3; i <= Math.sqrt(n); i += 2) {
- // While i divides n, print i and divide n
- while (n % i == 0) {
- n /= i;
- }
- }
- return n;
- }
- }
4)Delete Edge to minimize subtree sum difference
C++
- #include <bits/stdc++.h>
- using namespace std;
-
- /* DFS method to traverse through edges,
- calculating subtree sum at each node and
- updating the difference between subtrees */
- void dfs(int u, int parent, int totalSum,
- vector<int> edge[], int subtree[], int& res)
- {
- int sum = subtree[u];
-
- /* loop for all neighbors except parent and
- aggregate sum over all subtrees */
- for (int i = 0; i < edge[u].size(); i++)
- {
- int v = edge[u][i];
- if (v != parent)
- {
- dfs(v, u, totalSum, edge, subtree, res);
- sum += subtree[v];
- }
- }
-
- // store sum in current node's subtree index
- subtree[u] = sum;
-
- /* at one side subtree sum is 'sum' and other side
- subtree sum is 'totalSum - sum' so their difference
- will be totalSum - 2*sum, by which we'll update
- res */
- if (u != 0 && abs(totalSum - 2*sum) < res)
- res = abs(totalSum - 2*sum);
- }
-
- // Method returns minimum subtree sum difference
- int getMinSubtreeSumDifference(int vertex[],
- int edges[][2], int N)
- {
- int totalSum = 0;
- int subtree[N];
-
- // Calculating total sum of tree and initializing
- // subtree sum's by vertex values
- for (int i = 0; i < N; i++)
- {
- subtree[i] = vertex[i];
- totalSum += vertex[i];
- }
-
- // filling edge data structure
- vector<int> edge[N];
- for (int i = 0; i < N - 1; i++)
- {
- edge[edges[i][0]].push_back(edges[i][1]);
- edge[edges[i][1]].push_back(edges[i][0]);
- }
-
- int res = INT_MAX;
-
- // calling DFS method at node 0, with parent as -1
- dfs(0, -1, totalSum, edge, subtree, res);
- return res;
- }
-
- // Driver code to test above methods
- int main()
- {
- int vertex[] = {4, 2, 1, 6, 3, 5, 2};
- int edges[][2] = {{0, 1}, {0, 2}, {0, 3},
- {2, 4}, {2, 5}, {3, 6}};
- int N = sizeof(vertex) / sizeof(vertex[0]);
-
- cout << getMinSubtreeSumDifference(vertex, edges, N);
- return 0;
- }
5) Make palindrome code
python
- def isPalindrome(Str):
-
- Len = len(Str)
-
- if (Len == 1):
- return True
-
-
- ptr1 = 0
-
-
- ptr2 = Len - 1
-
- while (ptr2 > ptr1):
-
- if (Str[ptr1] != Str[ptr2]):
- return False
- ptr1 += 1
- ptr2 -= 1
-
- return True
-
- def noOfAppends(s):
-
- if (isPalindrome(s)):
- return 0
-
-
- del s[0]
-
- return 1 + noOfAppends(s)
-
- //allcoding1
- se = "abede"
- s = [i for i in se]
- print(noOfAppends(s))
6) Rectangular formation code in Python
8. Chair Game Code
9) LIS Problem
10. Prifix XOR code in Java
- // Java program to find the XOR of
- // all elements in the array
- class GFG {
-
- // Function to find the XOR of
- // all elements in the array
- static int xorOfArray(int arr[], int n)
- {
- // Resultant variable
- int xor_arr = 0;
-
- // Iterating through every element in
- // the array
- for (int i = 0; i < n; i++) {
-
- // Find XOR with the result
- xor_arr = xor_arr ^ arr[i];
- }
-
- // Return the XOR
- return xor_arr;
- }
-
- // Driver Code
- public static void main (String[] args)
- {
-
- int arr[] = { 3, 9, 12, 13, 15 };
- int n = arr.length;
-
- // allcoding1
- System.out.println(xorOfArray(arr, n));
-
- }
}
11. Python Computer game Code
12. Beautiful Binary String HackerRank Solution in C++
- #include <map>
- #include <set>
- #include <list>
- #include <cmath>
- #include <ctime>
- #include <deque>
- #include <queue>
- #include <stack>
- #include <string>
- #include <bitset>
- #include <cstdio>
- #include <limits>
- #include <vector>
- #include <climits>
- #include <cstring>
- #include <cstdlib>
- #include <fstream>
- #include <numeric>
- #include <sstream>
- #include <iostream>
- #include <algorithm>
- #include <unordered_map>
- using namespace std;
- char B[105];
- int main(){
- int n;
- int ans=0;
- scanf("%d", &n);
- scanf("%s", B);
- for(int i=2; B[i]; i++){
- if(B[i-2] == '0' && B[i-1] == '1' && B[i] == '0') B[i] = '1', ans++;
- }
- printf("%d", ans);
- return 0;
- }
Available
- Xor operation
- Rectangular operation
- Replace elements
- Xor operation
- Rectangular operation
- Replace elements
- Xor operation
- Rectangular operation
- Replace elements
- Available
- Xor operation
- Rectangular operation
- Replace elements
- Xor operation
- Rectangular operation
- Replace elements
- Xor operation
- Rectangular operation
- Replace elements
- Available
- Xor operation
- Rectangular operation
- Replace elements
- Xor operation
- Rectangular operation
- Replace elements
- Xor operation
- Rectangular operation
- Replace elements
- Filling seats code
- Maximum sum of minimum code
- Sort the array code
12. Replace element code
______________________________
______________________
Positive sum segment code in python
Maximum difference code in python 2
A lots of sum code in python
Maximize the multiplication
Make palindrome code in python
- def isPalindrome(Str):
-
- Len = len(Str)
-
- if (Len == 1):
- return True
-
-
- ptr1 = 0
-
-
- ptr2 = Len - 1
-
- while (ptr2 > ptr1):
-
- if (Str[ptr1] != Str[ptr2]):
- return False
- ptr1 += 1
- ptr2 -= 1
-
- return True
-
- def noOfAppends(s):
-
- if (isPalindrome(s)):
- return 0
-
-
- del s[0]
-
- return 1 + noOfAppends(s)
-
- se = "abede"
- s = [i for i in se]
- print(noOfAppends(s))
String Updation code
1.Happy hour code
2.Prime with square
3.Removing a character
1.Remove the balls
2.NHT
3.Removing a character
Infosys Specialist programer exam
Msps code
- // Online C++ compiler to run C++ program online
- #include <bits/stdc++.h>
- using namespace std;
- int func(int n){
- int cnt=0;
- for (int i=1; i<=sqrt(n); i++)
- {
- if (n%i == 0)
- {
- if (n/i == i)
- cnt++;
- else
- cnt+=2;
- }
- }
- return cnt;
- }
- int calcSum(int arr[], int n, int k)
- {
- int sum = 0;
- for (int i = 0; i < k; i++)
- sum += arr[i];
- int mx=func(sum);
-
- for (int i = k; i < n; i++) {
- sum = (sum - arr[i - k]) + arr[i];
- mx=max(mx,func(sum));
- }
- return mx;
- }
- int main() {
- // Write C++ code here
- int n,k;
- cin>>n>>k;
- int arr[n];
- for(int i=0;i<n;i++)
- cin>>arr[i];
-
- cout<<calcSum(arr, n, k)*k;
-
- return 0;
- }
rectangle code in python
- def rec(a):
- b=[]
- for i in range(len(a)):
- for j in range(len(a)):
- if a[i]!=a[j] and i!=j:
- area=a[i]*a[j]
- b.append(area)
- return max(b)
- if name== "main" :
- n=int(input())
- A=[]
- for i in range(n):
- A.append(int(input()))
- print(rec(A))
⚡️ Sequences concatenation code ⚡️
- ArrayList<Integer> ar = new ArrayList<Integer>();
- ArrayList<Integer> ar1 = new ArrayList<Integer>();
- ArrayList<Integer> arr2= new ArrayList<Integer>();
- ArrayList<Integer> sza= new ArrayList<Integer>();
- ArrayList<Integer> p_n= new ArrayList<Integer>();
- Scanner sc = new Scanner(System.in);
- int a_size= sc.nextInt();
- int m_size=sc.nextInt();
- int[] a = new int[a_size];
- for(int i=0;i<a_size;i++){
- a[i]=sc.nextInt();
- arr2.add(a[i]);
- }
- int[] p = new int[m_size];
- for(int i=0;i<m_size;i++){
- p[i]=sc.nextInt();
- p_n.add(p[i]);
- }
- int[] sz=new int[m_size];
- for(int i=0;i<m_size;i++){
- sz[i]=sc.nextInt();
- sza.add(sz[i]);
- }
- for(int i=0;i<a_size;i++)
- {
- for(int j=0;j<m_size;j++)
- {
- if(a[i]==p[j])
- {
- ar.add(p[j]);
- }
- }
- }
- int [] fr = new int [ar.size()];
- int visited = -1;
- for(int i = 0; i < ar.size(); i++){
- int count = 1;
- for(int j = i+1; j < ar.size(); j++){
- if(ar.get(i).equals(ar.get(j))){
- count++;
- fr[j] = visited;
- }
- }
- if(fr[i] != visited)
- fr[i] = count;
- }
-
- for(int i = 0; i < fr.length; i++){
- if(fr[i] != visited)
- ar1.add(fr[i]);
- }
- ArrayList<Integer> pnew = new ArrayList<Integer>();
- for(int l=0;l<sz.length;l++)
- {
- for(int h=0;h<sza.get(l);h++)
- {
- pnew.add(p_n.get(l));
- }
- }
- int count=0;
- for(int i = 0; i < pnew.size(); i++)
- {
⚡️ Sequences concatenation code ⚡️
_______________________
- def XorOfArray(n):
- x =0;
- for i in range(len(n)):
- x = x ^ n[i]
- return x
- def NoOfFactors(n):
- numcount = 0
- for i in range(2,n + 1):
- if n % i == 0:
- count = 1
- for j in range(2,(i//2 + 1)):
- if(i % j == 0):
- count = 0
- break
- if(count == 1):
- numcount+=1
- return numcount
- def MaxScore(n, k, A):
- maxs = 0
- for i in range((n - k)+ 1):
- subarr = []
- for j in range(i, i+k):
- subarr.append(A[j])
- xor = XorOfArray(subarr)
- if xor != 0:
- nofacts = NoOfFactors(xor)
- tempMax = nofacts * k
- if maxs < tempMax:
- maxs = tempMax
- return maxs
- n = int(input())
- k = int(input())
- A = []
- for i in range(n):
- A.append(int(input()))
- maxScr = MaxScore(n, k, A)
- print(maxScr)
__________________________
NGD code solution
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- int main()
- {
- map<int,int> s;
- s.insert({0,0});
- for(int i=1;i<=10000;i++)
- s.insert({i*i,1});
- int n;
- cin>>n;
- int a[n];int ans=0;
- for(int i=0;i<n;i++){
- cin>>a[i];
- int t=a[i]/2;
- for(int j=1;j*j<=t;j++){
- if(s[a[i]-j*j]==1)
- ans++;
- }
- }
- cout<<ans<<endl;
- }
_______________
⚡️ Prime With Squares Code ⚡️
Language : Python
____________________________
Equal array
Language - c++
Infosys dse and sp
____________________
Knapsack code done ✅
Language c++
Infosys dse sp
_______________________
Equal array code
LVP code in python
Good Pairs
Stream : Python 2
⚡️ MSSS code in python ⚡️
⚡️Beautiful binary string code⚡️
- #include <map>
- #include <set>
- #include <list>
- #include <cmath>
- #include <ctime>
- #include <deque>
- #include <queue>
- #include <stack>
- #include <string>
- #include <bitset>
- #include <cstdio>
- #include <limits>
- #include <vector>
- #include <climits>
- #include <cstring>
- #include <cstdlib>
- #include <fstream>
- #include <numeric>
- #include <sstream>
- #include <iostream>
- #include <algorithm>
- #include <unordered_map>
- using namespace std;
- char B[105];
- int main(){
- int n;
- int ans=0;
- scanf("%d", &n);
- scanf("%s", B);
- for(int i=2; B[i]; i++){
- if(B[i-2] == '0' && B[i-1] == '1' && B[i] == '0') B[i] = '1', ans++;
- }
- printf("%d", ans);
- return 0;
- }
⚡️ Prime with square ⚡️
⚡️GCD MAXIMIZATION code in java⚡️
⚡️Oblivious code ⚡️ Stream : JAVA 8
Happy hour code in python
|
Prime with Square |
Python bitwise operations
👉👉 Remove the character
Stream : C++
- int res = 0,i = 0;
- bool removed,valid;
- for(string& str : t)
- {
- i = 0; removed = false; valid = true;
- for(int j=0;j<(n-1);i++,j++)
- {
- if(s[i] == str[j]){continue;}
- if(removed){valid = false; break;}
- removed = true; j--;
- }
- if(valid){res++;}
- }
- return res;
MNC CODE IN C++
Share and support
⚡️Remove the characters in C++⚡️
- int res = 0,i = 0;
- bool removed,valid;
- for(string& str : t)
- {
- i = 0; removed = false; valid = true;
- for(int j=0;j<(n-1);i++,j++)
- {
- if(s[i] == str[j]){continue;}
- if(removed){valid = false; break;}
- removed = true; j--;
- }
- if(valid){res++;}
- }
- return res;
Ngd code
ReplyDeleteOblivious
Subsequent dist
String updation code
ReplyDeleteArranging numbers code
Happy hour
ReplyDeleteRectangle
Fibonacci strings
Bitwise operations and LCSS
ReplyDeleteSwap game code pls
ReplyDeleteMe too
DeleteSubsequence and distance
ReplyDeleteI hate max
Code pls
Organise the class
ReplyDeleteKnapsack again
Company hierarchy
GCD MAXIMIZATION
ReplyDeleteAmazing Sequence
ReplyDeleteSwap game code
ReplyDeleteString updation code
ReplyDeleteArranging numbers code
Most beautiful segment codes
Oblivios code bro please
ReplyDeleteOblivious code bro Please
ReplyDeleteOblivious code ?
ReplyDeleteFast sir please
ReplyDeleteReplace elements code
ReplyDeleteMSSS
ReplyDeleteSort the array and nkp code please
ReplyDeleteMather needs to clean
ReplyDeleteFilling seats
ReplyDeleteGCD maximization code plzzz
ReplyDeleteArranging numbers
ReplyDeleteLMPKA
ReplyDeleteAmazing Sequence code plzzzz
ReplyDeleteSend most beautiful segment
ReplyDeleteFilling seats
Number ways
Code please please it's a request
Oblivious code please
ReplyDeleteSubsequence and ditmstance code plss
ReplyDeleteSort the array code please
ReplyDeleteGCD maximization code plzz
ReplyDeleteSpecial subsequence
ReplyDeleteSwap game
Coin distribution
Book distribution code
ReplyDeleteRemove the ball
ReplyDeleteA bit hard problem
NHT
Bitwise operations and LCSS code please
ReplyDeleteSort the array is not there please upload
ReplyDeleteSubsequence and distance
ReplyDeleteI hate max code plsss
Remainder one
ReplyDeleteMax expertise
MNC
Code please
NGD code plzzz
ReplyDeleteRemove the balls
ReplyDeleteHappy hour
Amazing sequence
MSSKILLS code plz
ReplyDeleteKnapsack again!
ReplyDeleteRectangle
ReplyDeleteSum of segment
A bit hard problem
Subsequence and distance
ReplyDeleteI hate max code plss
Nkp code
ReplyDeletePrime with squares
ReplyDeleteMaher needs to clean
Or function
Filling seats code please
ReplyDeleteIncreasing sequence
ReplyDeleteSwap game
Replace elements
GCD maximization code plzzzz plzzz
ReplyDeleteFourlets count
ReplyDeleteMNC code plzzzzzzzzzzzzzz
Fourlets count
MNC code plzzzzzzzzzzzzzz
Sir plz MSSS code
ReplyDeleteAnd maximum possible score
MNC code plz sirrr
ReplyDeleteOR function code
ReplyDeleteArranging numbers code please
ReplyDeleteAmazing Sequence code plzzz
ReplyDeleteCompany hierarchy
ReplyDelete