- Backtracking, Strings

Least count of words required to construct a target String

import*;import java.util.*;  class Sol {              int[][] countMap;      int cnt = Integer.MAX_VALUE;              public int minStickers(String[] stickers                           , String target)    {                if (target == null)            return -1;          if (target.length() ==…

Read More

- Backtracking, Graph, Graph Traversals, graph-connectivity, graph-cycle, Recursion

Print all Hamiltonian Cycles in an Undirected Graph

  import java.util.ArrayList;class GFG {                  boolean isSafe(int v, int graph[][],                   ArrayList path,                   int pos)    {                                if (graph[path.get(pos – 1)][v]            == 0)            return false;                          for (int i = 0; i…

Read More

- Amazon, Backtracking, Hash, interview-preparation, Mathematical, Strings

Convert a Mobile Numeric Keypad sequence to equivalent sentence

import*;import java.lang.*;import java.util.*;public class GFG {                static void printSentence(String S)    {                String nums[]            = { “”,    “”,    “ABC”,  “DEF”, “GHI”,                “JKL”, “MNO”, “PQRS”, “TUV”,…

Read More