Remove Invalid Parentheses from an Expression in C++

Prateek Jangid
Updated on 26-Nov-2021 06:23:33

255 Views

Given a parentheses sequence; now, you have to print all the possible parentheses that it can make by removing the invalid brackets, for exampleInput : str = “()())()” - Output : ()()() (())() There are two possible solutions "()()()" and "(())()" Input : str = (v)())() Output : (v)()() (v())()In this problem, we are going to use backtracking so that it will print all the valid sequences.Approach to Find the SolutionIn this approach, we will be trying to remove the opening and closing brackets one by one using BFS. Now for each sequence, we check if it is valid ... Read More

Find Number of Ways to Go from One Point to Another in a Grid using C++

Prateek Jangid
Updated on 26-Nov-2021 06:23:16

269 Views

In this article, we are given a question in which we need to find the total number of ways from point A to B where A and B are fixed points, i.e., A is the top-left point in the grid and B is the bottom right point in the grid for example −Input : N = 5 Output : 252 Input : N = 4 Output : 70 Input : N = 3 Output : 20In the given problem, we can formalize the answer by simple observations and get our results.Approach to find The SolutionIn this approach, we ... Read More

Find Number of Unique Triplets Whose XOR is Zero Using C++

Prateek Jangid
Updated on 26-Nov-2021 06:16:23

560 Views

In this article, we will discuss counting the number of unique triplets (x, y, z) in a given array of unique numbers where their XOR is 0. Thus, triplets should be unique where all the three elements are unique and would count all the combinations of triplets for example −Input : arr[ ] = { 5, 6, 7, 1, 3 } Output : 2 Explanation : triplets are { 5, 6, 3 } and { 6, 7, 1 } whose XOR is zero. Input : arr[ ] = { 3, 6, 8, 1, 5, 4 , 12} Output : ... Read More

Remove Entry from HashMap in C++ While Iterating

Prateek Jangid
Updated on 26-Nov-2021 06:10:13

663 Views

Discuss how to remove an entry from HashMap using the value while iterating over it, for exampleInput: HashMap: { 1: “ Mango ”, 2: “ Orange ”, 3: “ Banana ”, 4: “Apple ” }, value=”Banana” Output: HashMap: { 1: “ Mango ”, 2: “ Orange ”, 4: “Apple ” }. Explanation: The third key-value pair is removed using the value “banana”. Input: HashMap: { 1: “Yellow”, 2: “White”, 3: “Green” }, value=”White” Output: HashMap: { 1: “Yellow”, 3: “Green” }.Approach to Find the SolutionIn C++, We can remove the element using the .erase() function. From ... Read More

Rearrange String in Sorted Order Followed by Integer Sum in C++

Prateek Jangid
Updated on 26-Nov-2021 06:07:01

917 Views

Discuss a problem to rearrange a string of alphabets in sorted order and add all the integers present in the string, for exampleInput : str = “adv4fc3” Output : “ acdfv7” Explanation: all the letters have been sorted to “acdfv” followed by the sum of integers 4 and 3. Input: str = “ h2d7e3f ” Output: “ defh12” Explanation: all the letters have been sorted to “defh” followed by the sum of integers 2, 7, and 3.Approach to Find the SolutionWe have two tasks to perform in this problem, one is sorting the string, and the other is adding ... Read More

Ratio of mth and nth Terms of an A.P. with Given Ratio of Sums

Prateek Jangid
Updated on 26-Nov-2021 06:05:41

166 Views

Discuss a problem where we are given a ratio of sums of m and n terms of A.P. We need to find the ratio of mth and nth terms.Input: m = 8, n = 4 Output: 2.142 Input: m = 3, n = 2 Output: 1.666 Input: m = 7, n = 3 Output: 2.6Approach to Find the SolutionTo find the ratio of mth and nth terms using code, we need to simplify the formula. Let Sm be the sum of first m terms and Sn be the sum of the first n terms of the A.P.a - ... Read More

Ranking Rows of Pandas DataFrame in Python

Prateek Jangid
Updated on 26-Nov-2021 06:03:47

1K+ Views

To add a column that contains the ranking of each row in the provided data frame that will help us to sort a data frame and determine the rank of a particular element, for example −Our DataframeName Play Time (in hours)Rate0Call Of Duty45Better than Average1Total Overdose46Good2GTA352Best3Bully22AverageOutputName Play Time (in hours)Rate ranking0Call Of Duty45Better than Average3.01Total Overdose46Good2.02GTA352Best1.03Bully22Average4.0Now, as you can see in the above example, our rankings are the whole numbers but have a decimal beside it, so that means we can have ranking in real numbers also, and that happens when more and one element have the same rank in ... Read More

Top Automation Testing Interview Questions and Answers

Vineet Nanda
Updated on 26-Nov-2021 06:02:18

1K+ Views

The following are some of the most often asked questions in interviews for both new and seasoned QA specialists.1. What exactly is automation testing?Automation testing is a process in which a tester's test scripts and cases are written and executed using an automation tool. The primary purpose of Automation Testing is to minimize the amount of test cases that must be executed physically, rather than to remove Manual Testing entirely.2. When are you going to automate a test?In the following situations, automation is desirable.Repeated TasksSmoke and Insanity ExamsExperiment with other data setsCases of regression testingTypically, the decision depends on the ... Read More

Range Sum Queries and Update with Square Root in C++

Prateek Jangid
Updated on 26-Nov-2021 06:01:53

359 Views

Given an array and several queries. Also, there are two types of query, i.e., update[ L, R ] means update elements from L to R with their square roots, and query[ L, R ] means to calculate the sum of elements from L to R.We are assuming a 1-based indexed array, for exampleInput: nums[ ] = { 0, 9, 4, 1, 5, 2, 3 }, Query[ ] = { {1, 1, 3}, {2, 1, 2}, {1, 2, 5}, { 1, 4, 5}} Output: 14 10 7 1st element of 1st query is 1 means we need to calculate range sum ... Read More

C++ Rat in a Maze with Multiple Steps or Jump Allowed

Prateek Jangid
Updated on 26-Nov-2021 06:00:30

399 Views

Given a n*n grid maze. Our rat is present in the top left corner of the grid. Now rats can only move down or forward, and if and only if the block has a non-zero value to it now in this variation rat is allowed to have multiple jumps. The maximum jump that the rat can take from the current cell is the number present in the cell, and now you are tasked to find if the rat can reach the bottom right corner of the grid, for example −Input : { { {1, 1, 1, 1}, {2, 0, 0, ... Read More

Advertisements