Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 1998 of 3366
2K+ Views
In this problem, we are given a robot that moves in all four directions but only one move. The directions are up(‘U’), down(‘D’), left(‘L’), right(‘R’). And we are given a string that contains initials of directions of the number. Our task is to print the final position of the robot, given the initial position of the robot is (0, 0).Let’s take an example to understand the problemInput − input: ‘LDRRUL’Output − (0, 0)Explanation −L (left) : (0, 0) -> (-1, 0) D (down) : (-1, 0) -> (-1, -1) R (right) : (-1, -1) -> (0, -1) R (right) : ... Read More
575 Views
In this problem, we are given two integers N and K. Our task is to find the index of Kth set a bit of the number N, counted from right.Set bits are checked from the binary representation of the number. The indexing in binary representation starts from index 0 from the right direction and propagates towards left.Example − in the binary number ‘011101’, at index 0 from right we have 1, at index 1 from right we have 0, and so on.Now, let’s take an example to understand the problemInput − N = 6, K = 2Output − 2Explanation − ... Read More
366 Views
In this problem, we are given an array and our task is to convert the array in such a way that all positive numbers are at even index places and all negative numbers are at odd index places.There might be an unequal number of positive and negative values, in this case, we will not move extra values.Let’s take an example to understand the problem, Input − {3, 5, -1, 19, -7, -2}Output − {3, -1, 5, -7, 19, -2}To solve this problem, we will have to find the element which is out of order in the array. There can be ... Read More
179 Views
In this problem, we are two string str1 and str2. Our task is to check whether all characters of str2 and present in str1.Let’s take an example to understand the problemInput −str1 = “Hello” str2 = “Hell”Output − yesExplanation − all characters of str2 are present in str1.To solve this problem, a simple solution will be checking each character of str2 in str1 and then returning the solution.But we need to create effective solutions. So, we will use a frequency array (length 256 for all valid characters) and then traverse str1 and increase the value in frequency array based on ... Read More
290 Views
In this problem, we are given a maze of n integers, each integer indicates the number of moves to be done. Along with the direction indicated using ‘>’ and ‘ < > >Output − YESExplanation − moving from start, we will move 2 positions ahead, then 1 position ahead, then 4 positions ahead. This will move our of the maze.To solve this problem, we will check whether moving out of the maze is possible or not. For this either we need to go below 0 or above n. Starting from 0, we will process the direction based on the sign ... Read More
174 Views
In this problem, we are given a large integer value (with up to 105 digits). Our task is to print the total number of cuts required such that maximum parts are divisible by 3.Let’s take an example to understand the problemInput − 9216Output − 3Explanation − the number is divided as 9|21|6.To solve this problem, we will have to start for the least significant bit of the number i.e. the last digit of the number. For here, we will find the smallest number divisible by three. And then update count based on it.Example − if arr[i] makes a 3 divisible ... Read More
1K+ Views
In this problem, we are given an m*n chessboard with filled positions marked by 1 i.e. if board[i][j] = 1, there is some piece there and we are given the starting position. Our task is to find the total number of possible moves for a knight in the board, if there are all pieces of the same color i.e. no attack will be done.Knight is chess is a piece that can move in all directions with some special sort of move. The moves of Knight in chess are −Two horizontal moves and a vertical move.Two vertical moves and a horizontal ... Read More
362 Views
In this problem, we are given an array of N integers denoting the length of n sticks. Our task is to print the count of rectangles and squares that can be created from the sticks of the given length.Let’s take an example to understand the problemInput − array = {5, 5, 7, 7, 1, 4}Output − 1Explanation − a rectangle with sides 5 5 7 7.To solve this problem, we will have to check if rectangles and squares are possible or not.Now, for creating a square or rectangle, there should be two sticks of the same length, 2 for rectangle and 4 for ... Read More
75 Views
In this problem, we are given two-digit timing using a glow digit display or seven-segment display (as in calculator). Our task is to calculate the possibility of occurrence of other timings that can occur by glowing or deleting one bit of the display.Seven-segment display is a special display that is used to display digits by glowing lines of the display.Sample of the seven-segment display is −Let’s take an example to understand the problem, Input − 7 5Output −Explanation − For 7, 5 numbers can be used to replace it. They are 9, 3, 8, 0, 7. For 5, 4 numbers ... Read More
5K+ Views
In this problem, we are given an array of integers. Our task is to check if the creation of a non-degenerate triangle taking the elements of the array as sides of the triangle.Non-degenerate triangle − it is a triangle that has a positive area. The condition for a non-degenerate triangle with sides a, b, c is −a + b > c a + c > b b + c > aLet’s take an example to understand the problem better −Input − arr[2, 5 ,9, 4, 3]Output − YesExplanation − the triangle formed is 2 3 4.To solve this problem, we ... Read More