-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotes
More file actions
93 lines (69 loc) · 4.54 KB
/
Notes
File metadata and controls
93 lines (69 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
1. To swap two number we can use XOR operator
a=5
b=6
a = a^b
b = a^b
a = a^b
2. b.erase(remove(b.begin(),b.end(),'0'),b.end());
3. Total sub array can be formed is-: n*(n+1)/2; with repeated element
3. to convert a string into number by left shifting the numbers
curr = curr*10+s[i]-'0'; in for loop
curr = curr*10+s[i++]-'0'; in while loop or some other
4. pq.push({-it.second,it.first});
// basically -sign make this max heap behave like a min heap
5. sort(v.begin(),v.end(),cmp);
bool cmp(pair<int,int>a,pair<int,int>b){
return a.second < b.second; // in ascedning order
// second because we need end time
}
this is an custom operator used in greedy aproach..
sorting based on end time .. (N meetings room *GFG*)
6. In coding, finding the GCD is a common problem, and there are various algorithms to compute it efficiently. Some well-known algorithms for finding the GCD include:
1. Euclidean Algorithm: It is an efficient method based on the principle that the GCD of two numbers is the same as the GCD of the smaller number and the remainder of the larger number divided by the smaller number.
2. Binary Euclidean Algorithm: A variation of the Euclidean algorithm that uses binary arithmetic for faster computation.
3. Stein Algorithm: Also known as the binary GCD algorithm, it is an efficient algorithm that uses bitwise operations.
7. When u want to change back to ur usrname or email use this command in git
git config --global user.name "<username>"
git config --global user.email "<email>"
git config --global user.name
<username>
git config --global user.email
<email>
git credential-cache exit
-- to roll back thet crendential that is active
git remote set-url origin "<link of your github repository>"
-- used to set the repository link
git branch -M <branch name>
-- to go <branch name> branch
8. Sure, here are 10 challenging string-based problems that are often asked in technical interviews, particularly for software engineering positions:
1. **Longest Palindromic Substring**:
- **Problem**: Given a string, find the longest substring which is a palindrome.
- **Example**: Input: "babad", Output: "bab" or "aba"
2. **Regular Expression Matching**:
- **Problem**: Implement a regular expression matching with support for '.' and '*'.
- **Example**: Input: s = "aab", p = "c*a*b", Output: true
3. **Word Break**:
- **Problem**: Given a string and a dictionary of words, determine if the string can be segmented into a space-separated sequence of one or more dictionary words.
- **Example**: Input: s = "leetcode", wordDict = ["leet", "code"], Output: true
4. **Minimum Window Substring**:
- **Problem**: Given a string S and a string T, find the minimum window in S which will contain all the characters in T.
- **Example**: Input: S = "ADOBECODEBANC", T = "ABC", Output: "BANC"
5. **Edit Distance**:
- **Problem**: Given two words, calculate the minimum number of operations required to convert one word into the other.
- **Example**: Input: word1 = "horse", word2 = "ros", Output: 3
6. **Longest Substring Without Repeating Characters**:
- **Problem**: Given a string, find the length of the longest substring without repeating characters.
- **Example**: Input: "abcabcbb", Output: 3 (substring "abc")
7. **Find All Anagrams in a String**:
- **Problem**: Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.
- **Example**: Input: s = "cbaebabacd", p = "abc", Output: [0, 6]
8. **String to Integer (atoi)**:
- **Problem**: Implement the `atoi` function which converts a string to an integer.
- **Example**: Input: "42", Output: 42
9. **Longest Common Subsequence**:
- **Problem**: Given two strings, find the length of their longest common subsequence.
- **Example**: Input: "abcde", "ace", Output: 3
10. **Decode Ways**:
- **Problem**: A message containing letters from A-Z is encoded to numbers using the following mapping: 'A' -> 1, 'B' -> 2, ..., 'Z' -> 26. Given a string, determine the total number of ways to decode it.
- **Example**: Input: "226", Output: 3 (possible decodings are "BZ", "VF", and "BBF")
These problems test various aspects of string manipulation, including searching, pattern matching, dynamic programming, and more. They are commonly used in interviews to assess a candidate's problem-solving skills and understanding of algorithmic concepts.