Day 57 of 360: Solving Coding Challenges and Practicing Git ๐Ÿš€

ยท

2 min read

Hello everyone,

Today marks Day 57 of my 360 Days of Learning journey, and it was a highly productive day filled with solving coding challenges and reinforcing my Git skills. ๐Ÿงฉโœจ

Problems Solved:

  1. Key Pair (GeeksforGeeks):

    • Problem: Find if there's a pair with a given sum in an array.

    • Approach: Instead of using a nested loop to check each pair, I used the two-pointer technique. First, I sorted the array using STL sort(), then iterated with two pointers to check if their sum matches the target value x. Depending on whether the sum was greater or less than x, I adjusted the pointers accordingly.

  2. Find Pivot Index (LeetCode Q724):

    • Problem: Find the pivot index where the sum of numbers to the left equals the sum of numbers to the right.

    • Approach: I utilized two vectors to store the left sum and right sum for each index. By iterating through the array and comparing the sums, I found the pivot index where both sums are equal.

  3. Missing Number (LeetCode Q268):

    • Problem: Find the missing number in a range from 0 to n.

    • Approach: I applied the XOR technique, where I XOR all elements from 0 to n and then XOR with the given array. This approach efficiently identifies the missing number. Another approach I considered was using the arithmetic progression formula to find the sum of all elements from 0 to n and subtracting the sum of the array elements.

  4. Maximum Subarray (LeetCode Q53):

    • Problem: Find the contiguous subarray with the maximum sum.

    • Approach: I used Kadane's algorithm, which efficiently computes the maximum subarray sum in linear time by iterating through the array and maintaining a running maximum sum.

Additional Achievements:

Apart from solving these questions, I also:

  • Revised GitHub Commands: I reviewed and practiced Git commands extensively. I applied what I learned by pushing my daily solved questions to GitHub using the skills I acquired yesterday.

  • Set Up a Server: Using my old desktop, I installed Linux, Apache, and Nginx, then forwarded the port to get remote access. This hands-on experience with SSH and server setup enhanced my practical skills.

Join Me on This Journey:

I invite you all to follow along, share your thoughts, and connect with me as I continue this year-long educational adventure. Your support and insights will be greatly appreciated!

ย