LeetCode_Interview_Questions_Solutions_Improved
LeetCode_Interview_Questions_Solutions_Improved
1. Array Questions
--------------------
if (map.containsKey(target - nums[i])) {
map.put(nums[i], i);
int maxProfit = 0;
return maxProfit;
}
if (!set.add(num)) {
return true;
return false;
int n = nums.length;
result[0] = 1;
int right = 1;
result[i] *= right;
}
return result;
return maxSum;
2. String Questions
--------------------
s[left] = s[right];
s[right] = temp;
left++;
right--;
}
}
count[s.charAt(i) - 'a']++;
count[t.charAt(i) - 'a']--;
if (c != 0) return false;
return true;
while (set.contains(s.charAt(right))) {
set.remove(s.charAt(left));
left++;
set.add(s.charAt(right));
maxLen = Math.max(maxLen, right - left + 1);
return maxLen;
2.4 Palindrome
if (!Character.isLetterOrDigit(s.charAt(left))) {
left++;
} else if (!Character.isLetterOrDigit(s.charAt(right))) {
right--;
return false;
} else {
left++;
right--;
return true;
if (numRows == 1) return s;
StringBuilder[] rows = new StringBuilder[numRows];
int currentRow = 0;
rows[currentRow].append(c);
goingDown = !goingDown;
result.append(row);
return result.toString();
3. Dynamic Programming
--------------------
if (n == 1) return 1;
first = second;
second = temp;
return second;
return maxSum;
4. Linked List
--------------------
prev = current;
current = nextTemp;
return prev;