ARTS Week 26

Algorithm

Input: nums = [3,2,1,5,6,4], k = 2
Output: 5
class Solution {
public int findKthLargest(int[] nums, int k) {
PriorityQueue<Integer> pq = new PriorityQueue<>();
for (int i = 0; i < nums.length; i++) {
if (i < k) {
pq.offer(nums[i]);
} else if (i >= k && nums[i] > pq.peek()) {
pq.poll();
pq.offer(nums[i]);
} else {
continue;
}
}
return pq.peek();
}
}

Review

  • Forget Business Cards and a Portfolio Site. The first thing you need to do is how to increase awareness and build a personal brand, not a business card and a personal website so your customers can find you.
  • Networking Is the Most Important Thing You Can Do. You need to build your own social network so that you can find your potential customers more effectively.
  • Beware of Freelance Platforms, They Are Evil. If a platform surveils access to your personal information by violating your privacy, it’s not good for you or the customer, so say “no” to those.
  • Say ‘Hello World’ in Real Life. If you are in college, make more friends; go to local gatherings in related fields, and try to meet more collaborators at the gatherings; contact more local businesses and tell them that you can help.

Tip

  • r+: support both read and write; but open will fail when the file does not exist; fseek can be used to adjust read and write offsets
  • w+: supports both reading and writing; but when the file does not exist, it will create a file and then open it; fseek can only be used to adjust the read offset
  • a+: supports both reading and writing; but when the file does not exist, it will create a file and then open it; fseek can only be used to adjust the read offset, and only write when writing to the end of the file

Share

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
KeepNewbie_yan

A programmer. Share knowledge of programming, operating system, Linux kernel, and reading, thinking etc. Let us maintain a beginner mend and grow together!