Hello Friends, I am PRIYANSHU NEMA work as a Full Stack Developer and I created this RU-vid channel (priyanshu placement solution) for share my experience and support you for any On/off Campus exam Preparation. Here we are discussing the Solution of MNC's Questions, Hiring Updates, and many more. So I request you Please Subscribe and Support our channel.
private static int minOperationsToReduceToOne(int n) { int operations = 0; // Counter to store the number of operations // Iterate until n becomes 1 while (n > 1) { boolean divided = false; // Flag to check if we were able to divide // Full for loop to find the largest divisor from n-1 to 2 for (int x = n - 1; x > 1; x--) { if (n % x == 0) { // If n is divisible by x n = n / x; // Divide n by x operations++; // Increment the operations count divided = true; // Set the flag to true break; // Exit the loop after the division } } // If no division happened, we subtract 1 from n if (!divided) { n -= 1; // Subtract 1 from n operations++; // Increment the operations count } } return operations; // Return the total number of operations } }
public class ubm2 { public static void main(String[] args) { int n=7; // it depends upon you int arr[]={1,2,3,4,5,7}; int j=0; int miss=0; for(int i=1;i<n;i++){ if(i!=arr[j]){ miss =i; } else{ j++; } } System.err.println(miss); } }
bro is there any problem if I use chatgpt chrome extension for copying while writing the willey edge online exam for placementis there any problem if I use chatgpt chrome extension for copying while writing the willey edge online exam for placement
user_array=list(input()) user_array=list(map(lambda x: int(x), user_array)) user_array.sort() print(user_array) numbers = list(range(len(user_array)+1)) print(numbers) missing_numbers = [] for i in numbers: if i in user_array: continue else: missing_numbers.append(i) print(missing_numbers)
Here is the logic for java... public static void main(String[] args) { int i,j; int n=5,c=1; int m=n*2-1; for(i=1;i<=m;i++) { for(j=1;j<=m;j++) { if (i==j || i+j==(n*2)) { System.out.print(c); } else{ System.out.print(" "); } } if(i<n) { c++; } else { c--; } System.out.println(); } } time complexity is O(n^2)
python: for i in range(1,10): for j in range(1,10): if(i==j and i<=5): print(i,end=' ') elif(i==j and i>5): print(10-i,end=' ') elif(i+j==10 and i<j): print(i,end=' ') elif(i+j==10 and i>j): print(j,end=' ') else: print(" ",end=' ') print()
WTF yar itne dino se wait kra tha 1st 10 min me dono code krke ho gaye 😖, 1st code mana ki thik hai ye galt hota hoga 2nd table print krne ka tha usme bhi same issue, Complaint Kiya raise ticket bhi Kiya close krdiya 😔, KISI ke pass solution hoga to batao
Bro kya ham hashmap, stl function, set, vector sabu use kar sakte he Accenture Mai, aur code kya scratch se likhna padega ya jaise leetcode mai hota hai waise
i think this is the best approach #include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; vector<vector<int>> mat(2*n-1,vector<int> (2*n-1,0)); int j=0; for(int i=0;i<n;i++){ mat[i][j]=min(i+1,j+1); mat[i][2*n-1-1-j]=mat[i][j]; mat[2*n-2-i][j]=mat[i][j]; mat[2*n-2-i][2*n-2-j]=mat[i][j]; j++; } for(int i=0;i<2*n-1;i++){ for(int j=0;j<2*n-1;j++){ cout<<mat[i][j]<<" "; } cout<<endl; } return 0; }
code in java: 👇👇 public class Solution { public static void main(String[] args) { String str = "E10:E20"; String s[] = str.split(":"); int a = s[0].codePointAt(0); //var b = s[0].substring(1); int b = Integer.parseInt(s[0].substring(1)); int c = s[1].codePointAt(0); //var d = s[0].substring(1); int d = Integer.parseInt(s[1].substring(1)); if(a == c && b == d ) { System.out.println("Invalid"); } else { int m = Math.abs(a-c)+1; int n = Math.abs(b-d)+1; System.out.println(n*m); } } }