Skip to main content

Command Palette

Search for a command to run...

Leetcode Contest Problems

Published
โ€ข1 min read
Leetcode Contest Problems
P

Hello, I'm Paras Kaushik! ๐Ÿ‘‹ I'm a dedicated software engineer based in India, specializing in C++ and proficient in the MERN stack.

๐Ÿค Interested in collaborating on innovative projects that require my technical expertise.

๐Ÿ’ฌ Passionate about participating in discussions related to software architecture and best practices.

๐Ÿ“ง Feel free to reach out to me via email: [paraskaushik12@gmail.com]

๐Ÿ”— Connect with me on LinkedIn: [https://www.linkedin.com/in/the-paras-kaushik/]

Leetcode Weekly Contest 387

3069. Distribute Elements Into Two Arrays I

3070. Count Submatrices with Top-Left Element and Sum Less Than k

This is a dynamic programming problem

3071.Minimum Operations to write `Y` on grid

We can clearly see via the constraints that is is a backtracking problem

3072. Distribute Elements Into Two Arrays II

The problem is a application problem of lower and upper bound :

Notes

  1. For set iterators arithmetic operations dont work like they do for array iterators ex. the operator - is not defined for the iterators of std::sets (bidirectional iterators) while it's defined for the arrays iterators (random access iterators).

    Instead, you can use std::distance(), as follows

     int main()
     {
         set<int> set {1, 2, 4, 5, 6};
         int number = 3;
         int lbIdx=distance(set.begin(), set.lower_bound(number)) ;
         cout<<"lower bound Index"<< lbIdx <<endl;
     }
    
18 views

More from this blog

Blogs by Paras

52 posts

Hello, I'm Paras Kaushik! ๐Ÿ‘‹ I'm a dedicated software engineer based in India, specializing in C++ and proficient in the MERN stack. ๐Ÿ’ผ Open to Collaboration