en
Feedback
MSBTE Computer and IT Engineering

MSBTE Computer and IT Engineering

Open in Telegram

Show more
The country is not specifiedThe category is not specified
2 125
Subscribers
-324 hours
-17 days
+1030 days
Posts Archive
Which is Best?
Anonymous voting

#3rdsem

CGR BOOKLET.pdf8.20 MB

DTE Booklet-EJCO3I(22320).pdf4.44 MB

🌀What is the C program to shutdown a computer in windows 10?🌀 The simplest way is to use the:- system(command); function in C to run the “shutdown.exe” file present in:- C programme:- #include <stdio.h> #include <conio.h> #include <stdlib.h> int main() { char c; printf("Enter Y/N: "); scanf("%c",&c); switch(c) { case 'Y': system("shutdown -s"); break; case 'N': ; break; default: ; break; } return 0; }@MSBTE_Computer_Branch

🌀Pack Include 🌀 ● C Handbook ● HTML & CSS Handbook ●JavaScript Handbook ✅ @MSBTE_Computer_Branch

Is Python more powerful programming language than C or C++? Python is capable of moving mountains. Python is the most powerful computing language ever devised. Python has an intuitive understanding of hardware that carries over into the person writing it. Python is capable of banging registers without side effects. Python is capable of representing register sets as structural objects with side effect for their access. Python was written by some of the elder gods of computer programming. Python is something I will be teaching my grandchildren, so that they can get a job, when everyone else has been replaced by robots. Python is so amazing that… Oh. Wait. I meant C. Not Python. Sorry for any confusion. Carry on. #!$*! pointers… ✅ @MSBTE_Computer_Branch

🌀 Facebook Coding Interview Question 🌀 Given a string, find the length of the longest substring without repeating characters. For example, the longest substrings without repeating characters for “ABDEFGABEF” are “BDEFGA” and “DEFGAB”, with length 6. Input: The first line of input contains an integer T denoting the number of test cases. The first line of each test case is str. Output: Print the length of the longest substring. Constraints: 1 ≤ T ≤ 500 1 ≤ str ≤ 5000 Sample Input 2 codesites qwertqwer Sample Output 7 5 Note: Test case 1: the longest substring is "codesites" and it's length is 7. Test case 2: The longest substring is "qwert" and it's length is 5. Try to do it in O(N) time complexity and O(N) space complexity! 🌀 Answer 🌀 This question is kind of hard question, but we will make it simple to understand! Follow me.. This problem follows the Sliding Window pattern and we can use a similar dynamic sliding window strategy. We can use a HashMap to remember the last index of each character we have processed. Whenever we get a repeating character we will shrink our sliding window to ensure that we always have distinct characters in the sliding window. Let's take an example of "abcaab". Here the answer is 3. and the string is "abc". What we are doing is take the first character. If the character is not in hashmap then add that character and go further denoting the max length. Now when the window becomes "abc" and next element is "a" you just have to shrink then window, which means now the length is also decreased. And go on with this pattern. And at last return the max length. That's it! Python 3: class Solution: def lengthOfLongestSubstring(self, str): window_start=0 max_length=0 char_frequency={} for window_end in range(len(str)): right_char = str[window_end] if right_char in char_frequency: window_start = max(window_start, char_frequency[right_char]+1) char_frequency[right_char] = window_end max_length = max(max_length, window_end-window_start+1) return max_length print(Solution().lengthOfLongestSubstring("codesites")) print(Solution().lengthOfLongestSubstring("abcaab")) Time Complexity The time complexity of the above algorithm will be O(N) where ‘N’ is the number of characters in the input string. Space Complexity The space complexity of the algorithm will be O(K) where K is the number of distinct characters in the input string. This also means K<=N, because in the worst case, the whole string might not have any repeating character so the entire string will be added to the HashMap. Having said that, since we can expect a fixed set of characters in the input string (e.g., 26 for English letters), we can say that the algorithm runs in fixed space O(1); in this case, we can use a fixed-size array instead of the HashMap. #Coding_interview_question ✅ @MSBTE_Computer_Branch

#6thsem By shubham Reddy Part 1- Click Here Part 2 - Click here@MSBTE_Computer_Branch

#6thsem By shubham Reddy ✅ @MSBTE_Computer_Branch

ETI_22618_UT1_Question_Bank_290120-1.pdf4.48 KB

🌀 Facebook Coding interview Question 🌀 Given a string S and a character X, return an array of integers representing the shortest distance from the character X in the string. Lets take input string as "codesites" and X="s" so the output is [4, 3, 2, 1, 0, 1, 2, 1, 0]. Because S[0] = "c", nearest "s" is at the distance 4 from "c". Same way S[1] = "o", nearest "s" is at the distance of 3 and continues. Assume that the solution always exists, means the character X is always there in the string S. Input Input consists of only one line containing a string. S string length is in [1, 10000]. All letters in S and C are lowercase. Output Output is also of one line, containing integers separated by a space. Sample Input Sample Output 4 3 2 1 0 1 2 1 0 🌀Answer 🌀 Intuition For each index S[i], let's try to find the distance to the next character C going left, and going right. The answer is the minimum of these two values. Algorithm When going left to right, we'll remember the index prev of the last character C we've seen. Then the answer is i - prev. When going right to left, we'll remember the index prev of the last character C we've seen. Then the answer is prev - i. We take the minimum of these two answers to create our final answer. Code: Python 3: def shortestDistance(S, X):     ans = []     prev = float('-inf')     for i in range(len(S)):         if S[i] == X:             prev = i         ans.append(i-prev)     prev=float('inf')     for i in range(len(S)-1,-1,-1):         if S[i] == X:             prev = i         ans[i] = min(ans[i], prev - i)     print(*ans) S = input() X = input() shortestDistance(S, X) Time Complexity Time Complexity: O(N), where N is the length of S. We scan through the string twice. Space Complexity Space Complexity: O(N), the size of ans. ✅ @MSBTE_Computer_Branch

🌀Google Coding interview question 🌀 Given an array (sorted in ascending order) and a value, count how many triplets exist in array whose sum is equal to the given value. Input: [1, 2, 3, 4, 5], 9 Output: 2 Output explanation: (1, 3, 5) and (2, 3, 4) Input The first line of the input contains integers seperated by a space n (1 ≤ n ≤ 1000) and (1 ≤ n[i] ≤ 10^5). Next Lines contains a single integer(1 ≤ k ≤ 1000). Output Output consists of one line containing integer. Sample Input 1 2 3 4 5 9 Sample Output 2 Note: If there is no such triplets you should return 0. Solution : First Approch: Fix the first element (i), move the second element (j) and search into the hashset. (similar approach to find_pairs_with_sum_k.py)  Time Complexity: O(N^2)  Space Complexity: O(N) def count_triplets(arr, k): count = 0     n = len(arr)     for i in range(n - 2):         elements = set()         curr_sum = k - arr[i]         for j in range(i + 1, n):             if (curr_sum - arr[j]) in elements:                 count += 1             elements.add(arr[j])     return count      arr=[1,2,3,4,5] k=9 print(count_triplets(arr,k)) Second Approch (Efficient): Fix the first element (i), and play with 2 pointers from the left (i+1) and right (n-1) side. If the current sum is smaller than K then increase the left pointer, otherwise decrease the right pointer. * This solution works only for elements in sorted ascending order. If the elements aren't sorted, first sort them and after that use this algorithm, the time complexity will be same O(NLogN + N^2) = O(N^2).     Time Complexity: O(N^2)     Space Complexity: O(1) def count_triplets(arr, k):     count = 0     n = len(arr)     for i in range(n - 2):         left = i + 1         right = n - 1         while left < right:             curr_sum = arr[i] + arr[left] + arr[right]             if curr_sum == k:                 count += 1                 right -= 1             elif curr_sum < k:                 left += 1             else:                 right -= 1     return count      arr=[1,2,3,4,5] k=9 print(count_triplets(arr,k)) ✅ @MSBTE_Computer_Branch

Which data type is most suitable for storing number 65000 in 32-bit system?
Anonymous voting