The rotation of lists has also been discussed earlier, but this particular article focuses on shorthand and various short tricks, implemented in a single line or a single word. This action is essential for programmers to accomplish a variety of tasks. Let’s discuss the different ways to rotate lists. Method 1: Use slices This particular approach is a…
Given two floating-point numbers, find the remainder. Example: Input: a = 36.5, b = 5.0Output: 1.5Input: a = 9.7, b = 2.3Output: 0.5 Recommendation: Please address the practice first, before proceeding with the solution. A simple solution is to do iterative subtraction. C ++ Java Python3 C# PHP Output: We can use the built-in fmod…
Given two integers N and K, the task is to generate an arrangement of N numbers (each number from 1 to N happens exactly once) such that the number of indexes for a [i]> a [i + 1] is exactly K. If such an arrangement is not possible, it is not possible to print. Example: Method: Since…
Given two integers “N” and “K”, the task is to find the sum of the digits “N” in odd digits (from right to left) and check if the sum is divisible by “K”. If divisible, the output is, otherwise output NO. Example: Input: N = 4325, K = 4Output: YES, because 3 + 5 = 8, divisible…
Of course, if you’re a programmer, you’ll be writing code, building projects, and you’ll be solving a lot of coding problems this year. What are the commonly used data structure algorithms? Let’s talk about data structures and algorithms and data structure algorithm collections…… The core of computer science and the breath of programmers living in the coding…
Salesforce visited MNIT Jaipur in the first week of September 2021 for a two-month SDE summer intern. Technique Test (75 minutes): This round is played on Hackerrank. There are 3 coding issues: A binary matrix is given. 1 represents a house, and a group of adjacent 1 is called a village. If two houses have a common…
Hill climbing is a heuristic search that is used for mathematical optimization problems in the field of artificial intelligence. Given a lot of input and good heuristics, it will try to find a good enough solution to the problem. The solution may not be the global optimal maximum. Features of mountain climbing 1. Variants of Build…
Vectors are known as dynamic arrays, capable of automatically resizing themselves when elements are inserted or deleted, and containers automatically handle their storage. A vector of a vector is a two-dimensional vector with a variable number of rows, where each row is a vector. Each index of a vector stores a vector, which can be…
Round 1: (Java Online Coding Challenge) This is an online coding challenge on Java (150 minutes). Webcam is a must-attend test. There are 3 questions: 1 easy, 1 medium and 1 hard. If we submitted the previous question, we can only move on to the next question. Problem 1: The first question is a simple…
We’ve discussed a simple iteration using two stacks after traversal in the previous article. In this article, the approach with only one stack is discussed. The idea is to use the left pointer to move down to the leftmost node. When moving down, push the root and the right substack of the root. Once you reach the…