Wednesday, 1 Dec 2021
Category: Technical Scripter

The tree is a hierarchical Data Structure. A binary tree is a tree that has at most two children. The node which is on the left of the Binary Tree is called “Left-Child” and the node which is the right is called “Right-Child”. Also, the smaller tree or the subtree in the left of the […]

#include using namespace std;    void assignValues(int Edges[], int n) {          vector tree[n + 1];             for (int i = 0; i < n - 1; i++) {            int u = Edges[i];         int v = Edges[i];         tree[u].push_back(v);         tree[v].push_back(u);     }                  vector visited(n + 1, false);             vector answer(n […]

import java.io.*; class GFG {                    static boolean isMatch(String text,                            String pattern)     {                  if (text == null || pattern == null) {             return false;         }                  int N = text.length();                  int M = pattern.length();                           boolean[][] dp = new boolean[N + 1][M + 1];                  dp = true;                   […]

In programming, the modulo operation gives the remainder or signed remainder of a division, after one integer is divided by another integer. It is one of the most used operators in programming. This article discusses when and why the modulo operation yields a negative result. Examples: In C, 3 % 2 returns 1. However, -3 […]

#include using namespace std;    #define ROW 4 #define COL 4    struct Point {     int x, y; };    struct Node {     Point pt;     int dist; };    bool isValid(int row, int col) {     return (row >= 0) && (col >= 0)            && (row < ROW) && (col < COL); }    int dRow[] […]

Maximize time by replacing ‘_’ in a given 24 Hour format time Given a string S representing a time in 24 hours format, with ‘_’ placed at positions of some digits, the task is to find the maximum time possible by replacing the characters ‘_’ with any digit. Examples: Input: S = “0_:4_”Output: 09:39Explanation: Replacing the […]

import java.io.*; import java.util.*;    class Edge {             int src;             int nbr;             int wt;             Edge(int src, int nbr, int wt)     {         this.src = src;         this.nbr = nbr;         this.wt = wt;     } }    class Pair implements Comparable {             int wsf;             String psf; […]

#include using namespace std;    void dfs(int src, vector Adj[],          vector& visited, int level,          int& distance) {             visited[src] = true;             distance = max(distance, level);                  for (auto& child : Adj[src]) {                              if (child != src             and visited[child] == false) {             dfs(child, Adj, visited,                 level + 1, […]

#include using namespace std;    void DFS(int src, vector Adj[],          int& ans, int arr[],          int currentMin, int currentMax) {             ans = max(         ans, max(abs(                      currentMax – arr[src – 1]),                  abs(currentMin – arr[src – 1])));             currentMin = min(currentMin,                      arr[src – 1]);        currentMax = min(currentMax,                      arr[src – 1]);                  for […]

Minimum removals required such that given string consists only of a pair of alternating characters Given a string S, the task is to find the minimum removal of characters required such that the string S consists only of two alternating characters. Examples: Input: S = “adebbeeaebd”Output: 7Explanation: Removing all occurrences of ‘b’ and ‘e’ modifies […]