2D-Arrays III Now that we've explored fundamental matrix operations—such as printing row-wise and column-wise, calculating sums, and identifying maximum and minimum values—let's dive deeper into specific matrix structures. One important concept is the classification of matrices based on their triangular properties. This leads us to the
2D- Arrays II As we have learnt the two types of traversal techniques that we can perform in a matrix. Now, it's very important for us to apply those in questions. Before , moving further we must make sure we are perfect with the row-wise and the column wise traversals. Q6. Maximum
2D-Arrays I Having covered the theoretical basics of 2D-Arrays in our previous discussion , let's now apply our basics in solving and understanding 2D-concepts more !! Q1. How to Print 2D array/matrix row-wise ? Example Input : mat[][] = {{1, 2, 3,4}, {5, 6, 7,8}, {9,10,11,12}} Output : Row-wise: 1
Prefix Sum Left and Right Sum Differences Problem Description Given a 0-indexed integer array nums, find a 0-indexed integer array answer where: 1) answer.length == nums.length. 2) answer[i] = |leftSum[i] - rightSum[i]|. Where: 1) leftSum[i] is the sum of elements to the left of the index i in the array nums. If there
My Calendar II Problem Description You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a triple booking. A triple booking happens when three events have some non-empty intersection (i.e., some moment is common to all the three events.
People Whose List of Favorite Companies is Not a Subset of Another List Solution In C++/Python/Java/Javascript Problem Description: Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorite companies for the i-th person (indexed from 0): Return the indices of people whose list of favorite companies is not a subset of any other list of favorite companies. You must return the indices in increasing
Shifting Letters II Problem Description You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [start i, end i, direction i]. For every i, shift the characters in s from the index start i to the index end i (inclusive) forward if direction i
Find the Maximum Number of Elements in Subset Solution In C++/Python/Java/Javascript Problem Description: You are given an array of positive integers nums. You need to select a subset of nums which satisfies the following condition: You can place the selected elements in a 0-indexed array such that it follows the pattern: [x, x², x⁴, ..., xᵏ/², xᵏ, xᵏ/², ..., x⁴, x², x] (Note
Assign Cookies Problem Statement Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor greed[i], which is the minimum size of a cookie that the child will be content with;
Lemonade Change Problem Statement At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You
Word Subsets Solution In C++/Python/Java/Javascript Problem Description: You are given two lists of words: words1 and words2. A word from words2 is called a subset of a word in words1 if: All the letters in the word from words2 are present in the word from words1. And each letter appears at least as many times
Car Pooling Problem Description There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west). You are given the integer capacity and an array trips where trips[i] = [numPassengers i, from i, to i] indicates that the ith trip has numPassengers
Pongal Bunk Problem Description Given a number N, which is the size of array where indices are from 1 to N . Initially all the elements of array are 0 . Q queries are given . Each query contains two variables L and R . For each query you have to perform the following operation: for
Minimum Number of Operations to Convert Time Problem Description You are given two strings current and correct representing two 24-hour times. 24-hour times are formatted as "HH:MM", where HH is between 00 and 23, and MM is between 00 and 59. The earliest 24-hour time is 00:00, and the latest is 23:59.
Minimum Operations to Make the Array Increasing Problem Description You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1. For example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3,3]. Return the minimum number
Points That Intersect With Cars Problem Description You are given a 0-indexed 2D integer array nums representing the coordinates of the cars parking on a number line. For any index i, nums[i] = [start i, end i] where start i is the starting point of the ith car and end i is the ending point
Groups of Special-Equivalent Strings Solution In C++/Python/Java/Javascript Problem Statement: You are given an array of strings of the same length words. In one move, you can swap any two even indexed characters or any two odd indexed characters of a string words[i]. Two strings words[i] and words[j] are special-equivalent if after any number of
Minimum Time to Type Word Using Special Typewriter Problem Description There is a special typewriter with lowercase English letters 'a' to 'z' arranged in a circle with a pointer. A character can only be typed if the pointer is pointing to that character. The pointer is initially pointing to the character 'a'
Optimal Partition of String Solution In C++/Python/Java/Javascript Problem Description: Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a single substring more than once. Return the minimum number of substrings in such a partition. Note that each character should
Sum of Unique Elements Solution In C++/Python/Java/Javascript Problem Description You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array. Return the sum of all the unique elements of nums. Example Input: nums = [1,2,3,2] Output: 4 Explanation: The unique elements are [1,
Maximum Population Year Problem Description You are given a 2D integer array logs where each logs[i] = [birth i, death i] indicates the birth and death years of the ith person. The population of some year x is the number of people alive during that year. The ith person is counted in year
Maximum Sum With Exactly K Elements Problem Description You are given a 0-indexed integer array nums and an integer k. Your task is to perform the following operation exactly k times in order to maximize your score: 1. Select an element m from nums. 2. Remove the selected element m from the array. 3. Add a
Count Number of Nice Subarrays Solution In C++/Python/java/JS Problem Description: Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it. Return the number of nice sub-arrays. Examples: Input: nums = [1,1,2,1,1], k = 3 Output: 2 Explanation: The only sub-arrays with 3
Find All Good Indices Problem Description You are given a 0-indexed integer array nums of size n and a positive integer k.We call an index i in the range k <= i < n - k good if the following conditions are satisfied: 1. The k elements that are just before the index
Movement of Robots Problem Description Some robots are standing on an infinite number line with their initial coordinates given by a 0-indexed integer array nums and will start moving once given the command to move. The robots will move a unit distance each second. You are given a string s denoting the direction