📅  最后修改于: 2023-12-03 15:32:49.102000             🧑  作者: Mango
面试是程序员职业生涯中不可避免的环节,MAQ软件也不例外。本套装将为您提供丰富的MAQ软件面试经验,包括面试题目、回答技巧等。希望能对您的面试有所帮助。
在面试前,需要准备好以下内容:
以下是一些MAQ软件在面试中经常出现的题目:
public boolean isPowerOfTwo(int n) {
if (n <= 0) {
return false;
}
return (n & (n - 1)) == 0;
}
public int[] merge(int[] nums1, int[] nums2) {
int len1 = nums1.length, len2 = nums2.length;
int[] merged = new int[len1 + len2];
int i = 0, j = 0, k = 0;
while (i < len1 && j < len2) {
if (nums1[i] < nums2[j]) {
merged[k++] = nums1[i++];
} else {
merged[k++] = nums2[j++];
}
}
while (i < len1) {
merged[k++] = nums1[i++];
}
while (j < len2) {
merged[k++] = nums2[j++];
}
return merged;
}
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
ListNode dummyHead = new ListNode(0);
ListNode p = l1, q = l2, curr = dummyHead;
int carry = 0;
while (p != null || q != null) {
int x = (p != null) ? p.val : 0;
int y = (q != null) ? q.val : 0;
int sum = carry + x + y;
carry = sum / 10;
curr.next = new ListNode(sum % 10);
curr = curr.next;
if (p != null) {
p = p.next;
}
if (q != null) {
q = q.next;
}
}
if (carry > 0) {
curr.next = new ListNode(carry);
}
return dummyHead.next;
}
public int lengthOfLongestSubstring(String s) {
int n = s.length(), ans = 0;
int[] index = new int[128];
for (int j = 0, i = 0; j < n; j++) {
i = Math.max(index[s.charAt(j)], i);
ans = Math.max(ans, j - i + 1);
index[s.charAt(j)] = j + 1;
}
return ans;
}
public class LRUCache<K, V> extends LinkedHashMap<K, V>{
private final int CACHE_SIZE;
public LRUCache(int cacheSize) {
super(16, 0.75f, true);
CACHE_SIZE = cacheSize;
}
protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
return size() > CACHE_SIZE;
}
}
public int findDuplicate(int[] nums) {
int slow = 0, fast = 0;
do {
slow = nums[slow];
fast = nums[nums[fast]];
} while (slow != fast);
slow = 0;
while (slow != fast) {
slow = nums[slow];
fast = nums[fast];
}
return slow;
}
public int search(int[] nums, int target) {
int left = 0, right = nums.length - 1;
while (left <= right) {
int mid = (left + right) / 2;
if (nums[mid] == target) {
return mid;
} else if (nums[mid] < target) {
left = mid + 1;
} else {
right = mid - 1;
}
}
return -1;
}
面试是一场考验人的综合素质的考试,需要充分准备和自信。本套装提供了丰富的MAQ软件面试经验,包括面试题目、回答技巧等,希望能帮助到大家在面试中取得好的成绩。