Open In App

Contest Experiences | LeetCode Weekly Contest 359

Last Updated : 30 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

About the Contest:

Date: 20th August, Sunday
Time: 8:00 AM (Weekly Contest)
Duration: 1 hour and 30 minutes
I recently participated in LeetCode Weekly Contest 359, a challenging coding competition that tests problem-solving skills and algorithmic thinking. This contest is held every Sunday at 8:00 AM and lasts for 1 hour and 30 minutes.

Prizes:

Rank

LeetCoin Prize

1

5000

2

2500

3

1000

4-50

300

51-100

100

101-200

50

Participate

5

First Time Participate

200

In addition to the LeetCoin prizes, there are extra rewards for the top performers:

  • 1st Place: Apple HomePod mini
  • 2nd Place: Logitech G903 LIGHTSPEED Gaming Mouse
  • 3rd to 5th Place: LeetCode Backpack
  • 6th to 10th Place: LeetCode water bottle
  • 11th to 20th Place: LeetCode Big O Notebook

These LeetCoins are redeemable for LeetCode merchandise. Participating in leetcode weekly contest not only offers a chance to earn rewards but also provides a platform to enhance problem-solving skills and compete with fellow programmers.

Link to the Contest: LeetCode-Weekly-359

Although the contest was a live event so it’s over but still you can access the virtual-contest and questions using the provided link.

Overview of Questions

Here’s an overview of the problems presented in LeetCode Weekly Contest 359:

Problem Number

Problem Title

Difficulty

Points

2828

Check if a String Is an Acronym of Words

EASY

3

2829

Determine the Minimum Sum of a k-avoiding Array

MEDIUM

4

2830

Maximize the Profit as the Salesman

MEDIUM

5

2831

Find the Longest Equal Subarray

MEDIUM

5

Discussion

Problem 2828 – Check if a String Is an Acronym of Words

Problem Statement: Given an array of strings words and a string s, determine if s is an acronym of words. The string s is considered an acronym of words if it can be formed by concatenating the first character of each string in words in order. For example, “ab” can be formed from [“apple”, “banana”], but it can’t be formed from [“bear”, “aardvark”]. Return true if s is an acronym of words, and false otherwise.

Approach: To solve this problem, we iterate through the characters in both s and words, comparing them to check if they form the desired acronym. We ensure that the lengths of s and words match for the comparison.

Problem 2829 – Determine the Minimum Sum of a k-avoiding Array

Problem Statement: You are given two integers, n and k. An array of distinct positive integers is called a k-avoiding array if there does not exist any pair of distinct elements that sum to k. Return the minimum possible sum of a k-avoiding array of length n.

Approach: The solution involves dynamic programming and the use of a map to keep track of selected elements and their sums while avoiding pairs that sum to k. We iteratively select elements to minimize the sum while ensuring no pair adds up to k.

Problem 2830 – Maximize the Profit as the Salesman

Problem Statement: You are given an integer n representing the number of houses on a number line, numbered from 0 to n – 1. Additionally, you are given a 2D integer array offers, where offers[i] = [starti, endi, goldi] indicates that theith’ buyer wants to buy all the houses from starti to endi for goldi amount of gold. As a salesman, your goal is to maximize your earnings by strategically selecting and selling houses to buyers. Return the maximum amount of gold you can earn.

Approach: The solution involves sorting the offers based on the end positions of house ranges. It employs dynamic programming to determine the maximum earnings while considering which houses to sell to buyers to maximize profits.

Problem 2831 – Find the Longest Equal Subarray

Problem Statement: You are given an integer array ‘nums‘ and an integer k. A subarray is called equal if all of its elements are equal. Note that the empty subarray is considered equal. Return the length of the longest possible equal subarray after deleting at most k elements from nums.

Approach: The solution employs a binary search approach to find the longest equal subarray while considering the constraints of deleting at most k elements. It maintains the maximum length using a segment tree-like structure.

Conclusion

I was able to solve the first 2 questions obtaining 7/17 points, but nevertheless I learned new things by attempting this contest.
These problems offered a diverse range of challenges and required different approaches to arrive at optimal solutions. Each problem tested different aspects of problem-solving and algorithmic skills.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads