Print All Palindromic Paths in a Matrix Using C++

sudhir sharma
Updated on 14-Jul-2020 07:36:48

224 Views

In this problem, we are given a matix which contains aplhabets (lowercase only) and we have to print all palidromic paths in the given matrix from top left to bottom right of the matrix.Allowed moves in this problem are right and down. Diagonal moves are not allowed.Let’s take an example to understand the problem −Input: matrix[][] ={    {"xxxy",    "yxxx",    "xyyx"} Output: xxxxxx , xxxxxx , xyxxyxExplainationLets see all valid moves from top left to bottom right using the position wrt to ith position.i00 -> i01 -> i02 -> i03 -> i13 -> i23 = xxxyxx i00 -> ... Read More

Print All Palindromic Partitions of a String in C++

sudhir sharma
Updated on 14-Jul-2020 07:35:42

217 Views

In this problem, we are given a palindromic string. And we have to print all the partitions of this string. In this problem, we will find all possible palindrome partitions of the string by cutting it.Let’s take an example to understand the problem -Input − string = ‘ababa’Output − ababa , a bab a, a b a b a ….The solution, to this problem, is to check if a substring is a palindrome or not. And print the substring if it is substring.ExampleThe below program will illustrate the solution − Live Demo#include using namespace std; bool isPalindrome(string str, int low, int ... Read More

Print All Palindrome Permutations of a String in C++

sudhir sharma
Updated on 14-Jul-2020 07:34:45

401 Views

In this problem, we are given a string and we have to print all the palindromic permutations that are possible from the characters of that string.Let’s take an example to understand the problem −Input − string = ‘aabb’Output − abba baabTo solve this problem we have to take the characters of the string and one by one generate all palindrome strings using these characters.Step 1 − Check if the string is a palindrome or not, print ‘Not Possible’ if not.Step 2 − If it can make palindrome, then make it into half and lexicographically select each letter of string.Step 3 ... Read More

Print All Pairs with Given Sum in C++

sudhir sharma
Updated on 14-Jul-2020 07:33:46

457 Views

In this problem, we are given an array of integers and an integer sum and we have to print all pairs of integers whose sum is equal to the sum value.Let’s take an example to understand the problem :Input − array = {1, 6, -2, 3} sum = 4Output − (1, 3) , (6, -2)Here, we need pairs with the given sum value.A simple solution to the problem will be checking pairs of elements that generate the sum. This can be done by traversing array and find the number in array that sums up to sum value.ExampleThis program will illustrate ... Read More

Using this and super Keywords with Lambda Expression in Java

raja
Updated on 14-Jul-2020 07:32:30

2K+ Views

The "this" and "super" references within a lambda expression are the same as in the enclosing context. Since the lambda expression doesn't define a new scope, "this" keyword within a lambda expression signifies "this" parameter of a method where the lambda expression is residing.In the below example, this.toString() calls the toString() method of the LambdaTest object but not the toString() method of the Operate instance.Example@FunctionalInterface interface Operate {    int func(int num1, int num2);    public String toString(); } public class LambdaTest {    public static void main(String[] args) {       LambdaTest test = new LambdaTest();       test.getResult();    } ... Read More

Implement IntConsumer Using Lambda and Method Reference in Java

raja
Updated on 14-Jul-2020 07:31:43

359 Views

IntConsumer interface is a functional interface from java.util.function package in Java 8. This interface accepts a single int-valued argument as input but doesn't produce any output. Since it is a functional interface, it can be used as an assignment target for a lambda expression or method reference. It contains one abstract method: accept() and one default method: andThen().Syntax@FunctionalInterface public interface IntConsumer {    void accept(int value); }Example of Lambda Expressionimport java.util.function.IntConsumer; public class IntConsumerTest1 {    public static void main(String[] args) {       IntConsumer displayNextInt = i -> System.out.println("Next Int Value: " + (i+1));  // lambda       IntConsumer displaySquare = ... Read More

Print All Paths from Source to Destination Using BFS in C++

sudhir sharma
Updated on 14-Jul-2020 07:28:01

1K+ Views

In this problem we are given a directed graph and we have to print all paths from the source to the destination of the graph using Breadth first Search (BFS).Directed graph is a graph in with edges that are directed from vertex a to b.Let’s take an example to understand the problem -Source = K destination = POutputK -> T -> Y -> A -> P K -> T -> Y -> P K -> A -> PHere, we have found paths from K to P. We have traversed paths and printed all paths from K that direct us to P.To ... Read More

Print All Permutation of a String Using ArrayList in Java

sudhir sharma
Updated on 14-Jul-2020 07:27:07

764 Views

In this problem, we are given a string of size n and we have to print all permutations of the string. But this time we have to print this permutation using ArrayList.Let’s take an example to understand the problem -Input − string = ‘XYZ’Output − XYZ, XZY, YXZ, YZX, ZXY, ZYXTo solve this problem, we will be generating all permutations of the character of the string. We will use a recursive function and will return arrayList.ExampleThe following is ArrayList implementation of the algorithm − Live Demoimport java.util.ArrayList; public class Main{    static void printArrayList(ArrayList combo) {       combo.remove("");   ... Read More

Print All Permutations with Repetition of Characters in C++

sudhir sharma
Updated on 14-Jul-2020 07:25:19

1K+ Views

In this problem, we are given a string of n characters and we have to print all permutations of characters of the string. Repeating of characters of the string is allowed. The printing of permutation should be done in alphabetical order (lexicographically sorted order).Let’s take an example to understand the topic better :Input − XYOutput − XX, XY, YX, YYTo solve this problem, we need to use fix and recur logic. Here, we will fix one element at first index of the array and then recursively call for the next elements in the sequence.Let’s see an implementation example which will ... Read More

Troubleshoot All System Issues in Windows Safe Mode

karthikeya Boyini
Updated on 14-Jul-2020 07:22:43

239 Views

Now, because of heavy or 24 hours uses of computer at corporate or home place, it becomes a complex and delicate machine. This complex and delicate machine sometime goes wrong while updating BIOS, downloading new drivers, or just surfing the Web. To resolve these issues user does not have to buy an expensive device or replace it with a new one.Microsoft provides a very useful Windows functions called Safe Mode functions. It’s always good to start windows in a safe mode to troubleshoot any kind of issues which give bad effects on the system. Although, using this mode only certain ... Read More

Advertisements