Snippets Collections
create or replace Trigger mytrigger2
after insert or update on employee
begin 
  case  
   when inserting then 
 dbms_output.put_line('Record  inserting');
  when updating then
    dbms_output.put_line('record updating');
  end case;
end;
/
DECLARE
    v_department_id NUMBER := &department_id;  -- Accept department number as input
BEGIN
    FOR emp_record IN (
        SELECT empno, ename, hiredate, deptno
        FROM employee
        WHERE deptno= v_department_id
    )
    LOOP
        DBMS_OUTPUT.PUT_LINE('Emp ID: ' || emp_record.empno);
        DBMS_OUTPUT.PUT_LINE('Name: ' || emp_record.ename);
        DBMS_OUTPUT.PUT_LINE('Hire Date: ' || TO_CHAR(emp_record.hiredate, 'YYYY-MM-DD'));
        DBMS_OUTPUT.PUT_LINE('Department ID: ' || emp_record.deptno);
        DBMS_OUTPUT.PUT_LINE('-----------------------------');
    END LOOP;
END;
/
create or replace procedure revers(ran in out integer)
Is
  num1 integer:=0;
  
   i integer;
begin 
   while (ran>0)
 loop
    i:=mod(ran,10);
    num1:=num1*10+i;
   ran:=trunc(ran/10); 
    end loop;
  dbms_output.put_line('reversed  number  ::'|| num1);
end;
/
declare 
  a integer:=&a;
begin 
  revers(a);
end;
/
  
CREATE TABLE empc (
    emp_id NUMBER PRIMARY KEY,
    name VARCHAR2(100),
    hire_date DATE
    -- other columns
);
DECLARE
    CURSOR emp_cursor IS
        SELECT empno, ename, hiredate
        FROM employee
        WHERE (SYSDATE - hiredate) / 365.25 >= 23;  -- Calculate experience in years
    emp_record emp_cursor%ROWTYPE;
BEGIN
    OPEN emp_cursor;
    LOOP
        FETCH emp_cursor INTO emp_record;
        EXIT WHEN emp_cursor%NOTFOUND;
        
        INSERT INTO empc (emp_id, name, hire_date)
        VALUES (emp_record.empno, emp_record.ename, emp_record.hiredate);
    END LOOP;
    CLOSE emp_cursor;
    
    COMMIT;
END;
/
create or replace procedure swap( num1 in out integer,num2 in out integer)
Is 
 temp integer:=0;

begin 
    temp:=num1;
    num1:=num2;
    num2:=temp;  
end;
/
declare 
  a integer:=&a;
  b integer:=&b;
begin 
  dbms_output.put_line('Before swaping '||a||'  '||b);
  swap(a,b);
   dbms_output.put_line('After swaping '||a||'  '||b);

end;
/
  
declare 
a integer:=&a;
c integer:=0;
i integer;
begin
   
   for i in 2 .. a-1
   loop
      if (mod(a,i)=0) then
         c:=c+1;
     end if;
    end loop;
  if c=0 
then 
   dbms_output.put_line('Prime number');
else
  dbms_output.put_line('Not Prime Number');
end if;
end;
/
     
 
create or replace Trigger mytrigger 
before insert on employee
begin 
 dbms_output.put_line('Record inserted ');
end;
/
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* deleteMiddle(ListNode* head) {

           ListNode* o=head;
           ListNode* t=head;
           ListNode* prev=head;
           if(head->next==NULL)
           {
            return head=NULL;
           }
           if(head->next->next==NULL)
           {
            delete head->next;
            head->next=NULL;
            return head;
           }
          while(t!=NULL && t->next!=NULL) 
           {
             if(t!=head)
             prev=prev->next;
             o=o->next;
             t=t->next->next; 
           }
           prev->next=o->next;
           delete o;
        return head;
    }
};
    ListNode* reverseList(ListNode* head)
    {ListNode* t1,*t2,*t3;
        t1 = head;
        if(head!=NULL)
         t2 = head->next;
        else
        return head;
        if(t2!=NULL)
        t3 = head->next->next;
        else
        {
            
            return head;
        }
        head->next=NULL;
        while(t3!=NULL)
        {
            t2->next=t1;
            t1=t2;
            t2=t3;
            t3=t3->next;
        }
        t2->next=t1;
        head = t2;
        return head;

    }
     
public class PiLambdaExpression{
    @FunctionalInterface
    interface PiValue{
        double getPi();
    }
    public static void main(String[] args) {
        PiValue pi = () -> Math.PI;
        double p= pi.getPi();
        System.out.println("The value of Pi is: " + p);
    }
}
public class BoundedArithematic<T extends Number> {
    public double add(T a, T b) {
        return a.doubleValue() + b.doubleValue();
    }
    public double subtract(T a, T b) {
        return a.doubleValue() - b.doubleValue();
    }
    public double multiply(T a, T b) {
        return a.doubleValue() * b.doubleValue();
    }	
   public double divide(T a, T b) {
        if (b.doubleValue() == 0) {
            throw new ArithmeticException("Division by zero is not allowed.");
        }
        return a.doubleValue() / b.doubleValue();
    }
    public static void main(String[] args) {
        BoundedArithematic<Number> calculator = new BoundedArithematic<>();
        Integer a = 10;
        Integer b = 5;
        System.out.println("Addition: " + calculator.add(a, b));
        System.out.println("Subtraction: " + calculator.subtract(a, b));
        System.out.println("Multiplication: " + calculator.multiply(a, b));
        System.out.println("Division: " + calculator.divide(a, b));
    }
}
==
//Wildcard Arguments
public class MagicBox<T> {
    private T item;

    public void addItem(T item) {
        this.item = item;
        System.out.println("Added item to the magic box: " + item);
    }

    public T getItem() {
                return item;
    }

    public void processBox(MagicBox<? super Integer> box) {
        System.out.println("Items in the box are processed["+box.getItem()+"]"); 
    }

    public static void main(String[] args) {
        
        MagicBox<Integer> integerBox = new MagicBox<>();
        integerBox.addItem(43);
        		
		MagicBox<String> stringBox = new MagicBox<>();
        stringBox.addItem("Sofiya");
        	
		
        MagicBox<Boolean> booleanBox = new MagicBox<>();
        booleanBox.addItem(false);
        
		MagicBox<Object> dobubleBox = new MagicBox<>();
        dobubleBox.addItem(43.43);
		
		integerBox.processBox(integerBox);
		dobubleBox.processBox(dobubleBox);
		
		
		
        
    }
}
#include <stdio.h>

void draw_inverted_triangle(int height) {
    for (int i = 0; i < height; ++i) {
        // Print leading spaces
        for (int j = 0; j < i; ++j) {
            putchar(' ');
        }

        // Print backslash
        putchar('\\');

        // Print inner spaces
        for (int j = 0; j < 2 * (height - i - 1); ++j) {
            putchar(' ');
        }

        // Print forward slash
        putchar('/');

        // Move to the next line
        putchar('\n');
    }
}

int main() {
    int height;

    // Get the height from the user
    printf("enter height: \n");
    scanf("%d", &height);

    // Print the top line of underscores
    for (int i = 0; i < 2 * height; ++i) {
        putchar('_');
    }
    putchar('\n');

    // Draw the inverted triangle
    draw_inverted_triangle(height);

    return 0;
}
ListNode* reverseList(ListNode* head) {
        stack<int> s;
        ListNode* t=head;
           while(t!=NULL)
           {
             s.push(t->val);
             t=t->next;
           }
           t=head;
             while(t!=NULL)
           {
             t->val = s.top();
             s.pop();
             t=t->next;
           }
           return head;
    
int search(vector<int>& nums, int target) {
        int low = 0;
        int n = nums.size();
        int high = n-1;
        
        while(high>=low){
            int mid = (high+low)/2;
        if(nums[mid]==target)return mid;
        else if(target>nums[mid])
        {
            low = mid+1;
        }
        else
        {
            high=mid-1;
        }
        }
        return -1;
    }
bool cmp(pair<int,int> a,pair<int,int> b)
{return a>b;}
sort(p.begin(),p.end(),cmp);
bool cmp(int a,int b)
{
  return a>b;
}
sort(v.begin(),v.end(),cmp);
//Remember in sort use cmp not cmp()
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Custom Menu')
      .addItem('Update Master Summary', 'updateMasterSummaryBasedOnConfiguration')
      .addItem('Update Configuration', 'updateConfiguration')
      .addItem('Update Consolidated Master', 'updateConsolidatedMaster')
      .addItem('Update Consolidated Rejected', 'updateConsolidatedRejected')
      .addItem('Synchronize Column with Template Dev Sheet', 'synchronizeHeadersWithTemplate')
      .addItem('Synchronize Column Name with Template Dev Sheet', 'synchronizeHeaderNamesWithTemplate') 

      .addToUi();
}

function updateMasterSummaryBasedOnConfiguration() {
  var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE", "TERMINATED"];

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var masterSheet = spreadsheet.getSheetByName("Master Summary");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Clear existing content in Master Summary sheet excluding the first column
  var rangeToClear = masterSheet.getRange("B:ZZ");
  rangeToClear.clear();

  // Get tab names and their statuses from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var tabNames = [];
  var tabStatuses = [];

  // Populate tabNames and tabStatuses arrays
  for (var i = 0; i < rangeData.length; i++) {
    var tabName = rangeData[i][0];
    var status = rangeData[i][1];
    if (tabName && status) { // Ensure both tab name and status exist
      tabNames.push(tabName);
      tabStatuses.push(status.toLowerCase()); // Convert status to lowercase for consistency
    }
  }

  // Set the headers for active tabs and count status for each tab
  var activeTabs = tabNames.filter(function(_, index) {
    return tabStatuses[index] === "active";
  });

  // Set the headers for active tabs in Master Summary
  var headerRowData = ['Status', 'Total Parts Count'].concat(activeTabs);
  masterSheet.getRange(1, 1, 1, headerRowData.length).setValues([headerRowData]);

  // Create a 2D array to hold all the data to be written to the Master Summary sheet
  var outputData = statusNames.map(function(statusName) {
    return [statusName, 0].concat(new Array(activeTabs.length).fill(0));
  });

  // Add a row for the total counts
  var totalCountsRow = ['TotTotal Parts Count', 0].concat(new Array(activeTabs.length).fill(0));
  outputData.push(totalCountsRow);

  // Iterate over active tabs and count the statuses
  activeTabs.forEach(function(tabName, tabIndex) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      var values = sheet.getRange("A:A").getValues().flat();
      var statusCounts = statusNames.reduce(function(counts, status) {
        counts[status] = 0;
        return counts;
      }, {});

      // Count the statuses
      values.forEach(function(value) {
        var upperValue = value.toString().toUpperCase();
        if (statusCounts.hasOwnProperty(upperValue)) {
          statusCounts[upperValue]++;
        }
      });

      // Fill the outputData array with counts
      statusNames.forEach(function(statusName, statusIndex) {
        var count = statusCounts[statusName] || 0;
        outputData[statusIndex][tabIndex + 2] = count; // Insert count into corresponding column
        outputData[statusIndex][1] += count; // Add count to the total column
        totalCountsRow[tabIndex + 2] += count; // Add count to the total row
      });
      totalCountsRow[1] += totalCountsRow[tabIndex + 2]; // Add total of current tab to the grand total
    }
  });

  // Write the collected data to the sheet in one operation
  masterSheet.getRange(2, 1, outputData.length, outputData[0].length).setValues(outputData);
}

function updateConfiguration() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Fetch existing sheet names from Configuration sheet
  var existingSheetNames = configSheet.getRange("A2:A").getValues().flat().filter(function(name) {
    return name; // Filter out empty values
  });

  // Fetch all sheet names excluding "Configuration" and "Master Summary"
  var allSheetNames = spreadsheet.getSheets().map(function(sheet) {
    return sheet.getName();
  }).filter(function(name) {
    return name !== "Configuration" && name !== "Master Summary";
  });

  // Filter out existing sheet names from all sheet names
  var newSheetNames = allSheetNames.filter(function(name) {
    return !existingSheetNames.includes(name);
  });

  // Append new sheet names to the Configuration sheet
  if (newSheetNames.length > 0) {
    var startRow = existingSheetNames.length + 2;
    configSheet.getRange(startRow, 1, newSheetNames.length, 1).setValues(newSheetNames.map(function(name) {
      return [name];
    }));

    // Calculate status for new sheet names
    var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE", "TERMINATED"];

    for (var k = 0; k < newSheetNames.length; k++) {
      var tabName = newSheetNames[k];
      var isActive = false;

      // Check each status for the current sheet
      for (var i = 0; i < statusNames.length; i++) {
        var status = statusNames[i];
        var count = getCountForStatusInSheet(status, tabName);
        if (count > 0) {
          isActive = true;
          break;
        }
      }

      // Set the status for the current sheet in the Configuration sheet
      var statusCell = configSheet.getRange(startRow + k, 2);
      statusCell.setValue(isActive ? "Active" : "Inactive");
      var statusValidationRule = SpreadsheetApp.newDataValidation()
          .requireValueInList(["Active", "Inactive"], true)
          .build();
      statusCell.setDataValidation(statusValidationRule);
      statusCell.setFontColor(isActive ? "#00FF00" : "#FF0000");
    }
  }
}

function getCountForStatusInSheet(status, sheetName) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
  
  // Return 0 if sheet doesn't exist
  if (!sheet) {
    return 0;
  }

  var statusColumn = sheet.getRange("A:A").getValues().flat(); // Assuming statuses are in column A

  // Count occurrences of status
  var count = statusColumn.filter(function(value) {
    return value === status;
  }).length;

  return count;
}

 
function updateConsolidatedMaster() {
  var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE"];
  var columnsToCopy = ["Status", "Start Date", "Part Type", "HOL P/N", "OE#", "ALT OE", "MAM Status (change to Dev)", "FP Status (Change to Electronically Announced)", "PartCat Status (Changed to Electronically Announced)", "Interchange", "Interchange Completion", "Parts List/RFQ Submitted to Warren", "Parts List/RFQ Returned to Holstein", "Production Sourced Part is requested from Warren", "ETA of Sample", "Date Prod Sample Delivered to Holstein", "Factory Code"];

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();

  try {
    var masterSheet = spreadsheet.getSheetByName("Consolidated Master");
    var configSheet = spreadsheet.getSheetByName("Configuration");

    // Clear existing content in Consolidated Master sheet
    masterSheet.clear();

    // Get active tab names and their statuses from the Configuration sheet
    var rangeData = configSheet.getRange("A:B").getValues();
    var activeTabs = rangeData.filter(function(row) {
      return row[1] && row[1].toLowerCase() === "active";
    }).map(function(row) {
      return row[0];
    });

    // Initialize variables
    var allData = [];
    var rowIndex = 2;

    // Insert headers
    allData.push(columnsToCopy.concat("MOQ")); // Add MOQ to the header row
    masterSheet.getRange(1, 1, 1, allData[0].length).setValues([allData[0]]);

    // Iterate through active tabs
    activeTabs.forEach(function(tabName) {
      var sheet = spreadsheet.getSheetByName(tabName);
      if (sheet) {
        var sheetData = sheet.getDataRange().getValues();

        // Get column names
        var columnNames = sheetData[1];

        // Iterate through rows (excluding header rows)
        sheetData.slice(2).forEach(function(row) {
          var status = row[0];

          // Check if status is in the list and copy relevant data
          if (statusNames.includes(status)) {
            var rowData = [status];
            columnsToCopy.forEach(function(col) {
              var colIndex = columnNames.indexOf(col);
              if (colIndex !== -1) {
                rowData.push(row[colIndex]);
              }
            });

            // Find MOQ column index and convert date to "1" if found
            var moqIndex = columnNames.indexOf("MOQ");
            if (moqIndex !== -1) {
              var moqValue = row[moqIndex];
              if (typeof moqValue === 'object' && moqValue instanceof Date) {
                rowData.push("1");
              } else {
                rowData.push(moqValue);
              }
            } else {
              rowData.push(""); // Add empty string if MOQ column not found
            }
            allData.push(rowData);
          }
        });
      }
    });

    // Insert all data at once
    if (allData.length > 1) { // Check if there's data to insert
      masterSheet.getRange(rowIndex, 1, allData.length - 1, allData[0].length).setValues(allData.slice(1));
    }
  } catch (error) {
    // Handle errors gracefully (e.g., log error or display message to user)
    console.error("Error occurred:", error);
  }
}


function updateConsolidatedRejected() {
  var statusNames = ["PIES REJECTED"];
  var columnsToCopy = ["STATUS", "Part Type", "HOL P/N", "OE#", "QC Inspection/PIES Collection", "HOL Feedback Sent", "New Sample Requested", "New Sample Received"];
 
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var masterSheet = spreadsheet.getSheetByName("Consolidated Rejected");
  var configSheet = spreadsheet.getSheetByName("Configuration");
 
  // Clear existing content in Consolidated Rejected sheet
  masterSheet.clear();
 
  // Get tab names and their statuses from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });
 
  // Initialize a variable to keep track of the row to insert data into
  var rowIndex = 2;
 
  // Insert headers for the Consolidated Rejected sheet
  var headers = columnsToCopy;
  masterSheet.getRange(1, 1, 1, headers.length).setValues([headers]);
 
  // Iterate through each active tab
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      var sheetData = sheet.getDataRange().getValues();
 
      // Get the column names from the second row
      var columnNames = sheetData[1];
 
      // Iterate through each row in the sheet
      sheetData.forEach(function(row, rowIdx) {
        if (rowIdx === 0 || rowIdx === 1) return; // Skip the header rows
 
        var status = row[0]; // Assuming status is in the first column (A)
 
        // If the status is "TERMINATED" or "PIES REJECTED", add it to the Consolidated Rejected sheet
        if (statusNames.includes(status)) {
          var rowData = [];
 
          // Insert the data into the Consolidated Rejected sheet
          columnsToCopy.forEach(function(col) {
            var colIndexInSheet = columnNames.indexOf(col);
            if (colIndexInSheet !== -1) {
              rowData.push(row[colIndexInSheet]);
            } else if (col === "STATUS") {
              rowData.push(status); // Add status directly for the STATUS column
            } else {
              rowData.push(''); // Fill in with an empty string if the column is not found
            }
          });
 
          masterSheet.getRange(rowIndex, 1, 1, rowData.length).setValues([rowData]);
          rowIndex++;
        }
      });
    }
  });
}

function synchronizeHeadersWithTemplate() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var templateSheet = spreadsheet.getSheetByName("Template Development Sheet");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Error handling for missing sheets
  if (!templateSheet) {
    SpreadsheetApp.getUi().alert('Error: "Template Development" sheet not found.');
    return;
  }
  if (!configSheet) {
    SpreadsheetApp.getUi().alert('Error: "Configuration" sheet not found.');
    return;
  }

  // Get the first two header rows from the Template Development sheet
  var templateHeaders = templateSheet.getRange(1, 1, 2, templateSheet.getLastColumn()).getValues();
  
  // Get active tab names from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });

  // Iterate through each active tab and synchronize headers
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      // Get the current headers of the active tab
      var currentHeaders = sheet.getRange(1, 1, 2, sheet.getLastColumn()).getValues();

      // Find new columns that are in the template but not in the current sheet
      var newColumns = [];
      var existingColumns = [];
      templateHeaders[1].forEach(function(header, index) {
        if (header) {
          var currentHeaderIndex = currentHeaders[1].indexOf(header);
          if (currentHeaderIndex === -1) {
            newColumns.push({
              header: header,
              templateColumnIndex: index
            });
          } else {
            existingColumns.push({
              currentHeaderIndex: currentHeaderIndex,
              templateColumnIndex: index
            });
          }
        }
      });

      // If there are new columns, add them to the current sheet
      if (newColumns.length > 0) {
        newColumns.forEach(function(column) {
          var columnIndex = column.templateColumnIndex + 1; // Adjust for 1-based index in Sheets
          
          // Insert a new column at the correct position
          sheet.insertColumnBefore(columnIndex);

          // Set the new header values
          sheet.getRange(1, columnIndex, 2, 1).setValues([
            [templateHeaders[0][column.templateColumnIndex]],
            [column.header]
          ]);

          // Shift data to include the new column
          var dataRange = sheet.getRange(3, columnIndex, sheet.getLastRow() - 2, 1);
          var dataValues = dataRange.getValues();
          for (var row = 0; row < dataValues.length; row++) {
            dataValues[row][0] = ""; // Set the new column values to empty
          }
          dataRange.setValues(dataValues);
        });
      }

      // Find columns that are in the current sheet but not in the template and remove them
      var columnsToDelete = [];
      currentHeaders[1].forEach(function(header, index) {
        if (header && !templateHeaders[1].includes(header)) {
          columnsToDelete.push(index + 1); // Adjust for 1-based index in Sheets
        }
      });

      // If there are columns to delete, remove them from the current sheet
      if (columnsToDelete.length > 0) {
        // Sort columns to delete in descending order to avoid shifting issues
        columnsToDelete.sort(function(a, b) { return b - a; });

        columnsToDelete.forEach(function(columnIndex) {
          sheet.deleteColumn(columnIndex);
        });
      }
    }
  });
}



function synchronizeHeaderNamesWithTemplate() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var templateSheet = spreadsheet.getSheetByName("Template Development Sheet");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Error handling for missing sheets
  if (!templateSheet) {
    SpreadsheetApp.getUi().alert('Error: "Template Development" sheet not found.');
    return;
  }
  if (!configSheet) {
    SpreadsheetApp.getUi().alert('Error: "Configuration" sheet not found.');
    return;
  }

  // Get the header rows from the Template Development sheet
  var templateHeaders = templateSheet.getRange(1, 1, 2, templateSheet.getLastColumn()).getValues();

  // Get active tab names from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });

  // Iterate through each active tab and synchronize header names
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      // Get the current headers of the active tab
      var currentHeaders = sheet.getRange(1, 1, 2, sheet.getLastColumn()).getValues();

      // Iterate through each header in the template sheet
      templateHeaders.forEach(function(templateRow, rowIndex) {
        templateRow.forEach(function(templateHeader, columnIndex) {
          var currentHeader = currentHeaders[rowIndex][columnIndex];
          // If the header name in the template sheet is different from the header name in the active tab
          if (templateHeader !== currentHeader) {
            // Update the header name in the active tab
            sheet.getRange(rowIndex + 1, columnIndex + 1).setValue(templateHeader);
          }
        });
      });
    }
  });
}


Example 1. without virtual keyword / Using scope resolution
#include <iostream>

using namespace std;

class classA {
    public:
    int a;
};

class classB : public classA {
    public:
    int b;
};
class classC : public classA {
    public:
    int c;
};
class classD : public classB, public classC {
    public:
    int d;
    
};

int main() {
   
   classD objD;
   //objD.a; Error
   
   objD.classB::a = 100; // this way is correct
   objD.classC::a = 200;
   
   cout<<"A from classB = "<<objD.classB::a<<endl;
   cout<<"A from classc = "<<objD.classC::a<<endl;
   objD.b = 10;
   objD.c = 20;
   objD.d = 30;
   cout<<"B = "<<objD.b<<endl;
   cout<<"C = "<<objD.c<<endl;
   cout<<"D = "<<objD.d<<endl;
   
    
    return 0;
}
//Output:
A from classB = 100
A from classc = 200
B = 10
C = 20
D = 30

_______________________________________________________________-
  
  Example 2. Using Virtual Kwyeord
  #include <iostream>

using namespace std;

class classA {
    public:
    int a;
};

class classB : virtual public classA {
    public:
    int b;
};
class classC : virtual public classA {
    public:
    int c;
};
class classD : public classB, public classC {
    public:
    int d;
    
};

int main() {
   
   classD objD;
   
   objD.a = 100; // is correct using virtual keyword. we can access a value from one copy.
   cout<<"Using Virtual keyword: "<<endl;
   classB objB;
   objB.a =600;
   cout<<"A from class B = "<<objB.a<<endl;
   cout<<"A from class D = "<<objD.a<<endl;
   objD.b = 10;
   objD.c = 20;
   objD.d = 30;
   cout<<"B = "<<objD.b<<endl;
   cout<<"C = "<<objD.c<<endl;
   cout<<"D = "<<objD.d<<endl;
   
    
    return 0;
}
//Output:
Using Virtual keyword: 
A from class B = 600
A from class D = 100
B = 10
C = 20
D = 30
<div class="ag-format-container">

  <div class="ag-courses_box">

    <div class="ag-courses_item">

      <a href="#" class="ag-courses-item_link">

        <div class="ag-courses-item_bg"></div>

​

        <div class="ag-courses-item_title">

          UI/Web&amp;Graph design for teenagers -&#0;years old

        </div>

​
11
        <div class="ag-courses-item_date-box">

          Start:

          <span class="ag-courses-item_date">

            04.11.

          </span>
16
        </div>
17
      </a>

    </div>

​
20
    <div class="ag-courses_item">

      <a href="#" class="ag-courses-item_link">
22
        <div class="ag-courses-item_bg"></div>

​
.ag-format-container {

  width: 2px;

  margin: 0 auto;
4
}

​

​

body {

  background-color: #000;

}

.ag-courses_box {
11
  display: -webkit-box;

  display: -ms-flexbox;

  display: flex;

  -webkit-box-align: start;

  -ms-flex-align: start;

  align-items: flex-start;

  -ms-flex-wrap: wrap;

  flex-wrap: wrap;

​

  padding: 50px 0;

}

.ag-courses_item {

  -ms-flex-preferred-size: calc(33.33333% - 30px);

  flex-basis: calc(33.33333% - 30px);
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Custom Menu')
      .addItem('Update Master Summary', 'updateMasterSummaryBasedOnConfiguration')
      .addItem('Update Configuration', 'updateConfiguration')
      .addItem('Update Consolidated Master', 'updateConsolidatedMaster')
      .addItem('Update Consolidated Rejected', 'updateConsolidatedRejected')
      .addItem('Synchronize Column with Template Dev Sheet', 'synchronizeHeadersWithTemplate')
      .addItem('Synchronize Column Name with Template Dev Sheet', 'synchronizeHeaderNamesWithTemplate') 


      .addToUi();
}

function updateMasterSummaryBasedOnConfiguration() {
  var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE", "TERMINATED"];

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var masterSheet = spreadsheet.getSheetByName("Master Summary");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Clear existing content in Master Summary sheet excluding the first column
  var rangeToClear = masterSheet.getRange("B:ZZ");
  rangeToClear.clear();

  // Get tab names and their statuses from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var tabNames = [];
  var tabStatuses = [];

  // Populate tabNames and tabStatuses arrays
  for (var i = 0; i < rangeData.length; i++) {
    var tabName = rangeData[i][0];
    var status = rangeData[i][1];
    if (tabName && status) { // Ensure both tab name and status exist
      tabNames.push(tabName);
      tabStatuses.push(status.toLowerCase()); // Convert status to lowercase for consistency
    }
  }

  // Set the headers for active tabs and count status for each tab
  var activeTabs = tabNames.filter(function(_, index) {
    return tabStatuses[index] === "active";
  });

  // Set the headers for active tabs in Master Summary
  var headerRowData = ['Status', 'Total Parts Count'].concat(activeTabs);
  masterSheet.getRange(1, 1, 1, headerRowData.length).setValues([headerRowData]);

  // Create a 2D array to hold all the data to be written to the Master Summary sheet
  var outputData = statusNames.map(function(statusName) {
    return [statusName, 0].concat(new Array(activeTabs.length).fill(0));
  });

  // Add a row for the total counts
  var totalCountsRow = ['TotTotal Parts Count', 0].concat(new Array(activeTabs.length).fill(0));
  outputData.push(totalCountsRow);

  // Iterate over active tabs and count the statuses
  activeTabs.forEach(function(tabName, tabIndex) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      var values = sheet.getRange("A:A").getValues().flat();
      var statusCounts = statusNames.reduce(function(counts, status) {
        counts[status] = 0;
        return counts;
      }, {});

      // Count the statuses
      values.forEach(function(value) {
        var upperValue = value.toString().toUpperCase();
        if (statusCounts.hasOwnProperty(upperValue)) {
          statusCounts[upperValue]++;
        }
      });

      // Fill the outputData array with counts
      statusNames.forEach(function(statusName, statusIndex) {
        var count = statusCounts[statusName] || 0;
        outputData[statusIndex][tabIndex + 2] = count; // Insert count into corresponding column
        outputData[statusIndex][1] += count; // Add count to the total column
        totalCountsRow[tabIndex + 2] += count; // Add count to the total row
      });
      totalCountsRow[1] += totalCountsRow[tabIndex + 2]; // Add total of current tab to the grand total
    }
  });

  // Write the collected data to the sheet in one operation
  masterSheet.getRange(2, 1, outputData.length, outputData[0].length).setValues(outputData);
}

function updateConfiguration() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Fetch existing sheet names from Configuration sheet
  var existingSheetNames = configSheet.getRange("A2:A").getValues().flat().filter(function(name) {
    return name; // Filter out empty values
  });

  // Fetch all sheet names excluding "Configuration" and "Master Summary"
  var allSheetNames = spreadsheet.getSheets().map(function(sheet) {
    return sheet.getName();
  }).filter(function(name) {
    return name !== "Configuration" && name !== "Master Summary";
  });

  // Filter out existing sheet names from all sheet names
  var newSheetNames = allSheetNames.filter(function(name) {
    return !existingSheetNames.includes(name);
  });

  // Append new sheet names to the Configuration sheet
  if (newSheetNames.length > 0) {
    var startRow = existingSheetNames.length + 2;
    configSheet.getRange(startRow, 1, newSheetNames.length, 1).setValues(newSheetNames.map(function(name) {
      return [name];
    }));

    // Calculate status for new sheet names
    var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE", "TERMINATED"];

    for (var k = 0; k < newSheetNames.length; k++) {
      var tabName = newSheetNames[k];
      var isActive = false;

      // Check each status for the current sheet
      for (var i = 0; i < statusNames.length; i++) {
        var status = statusNames[i];
        var count = getCountForStatusInSheet(status, tabName);
        if (count > 0) {
          isActive = true;
          break;
        }
      }

      // Set the status for the current sheet in the Configuration sheet
      var statusCell = configSheet.getRange(startRow + k, 2);
      statusCell.setValue(isActive ? "Active" : "Inactive");
      var statusValidationRule = SpreadsheetApp.newDataValidation()
          .requireValueInList(["Active", "Inactive"], true)
          .build();
      statusCell.setDataValidation(statusValidationRule);
      statusCell.setFontColor(isActive ? "#00FF00" : "#FF0000");
    }
  }
}

function getCountForStatusInSheet(status, sheetName) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
  
  // Return 0 if sheet doesn't exist
  if (!sheet) {
    return 0;
  }

  var statusColumn = sheet.getRange("A:A").getValues().flat(); // Assuming statuses are in column A

  // Count occurrences of status
  var count = statusColumn.filter(function(value) {
    return value === status;
  }).length;

  return count;
}

 
function updateConsolidatedMaster() {
  var statusNames = ["RFQ SENT", "PART NUMBER SET UP", "SOURCED", "DEVELOPING", "AWAITING SAMPLE", "SAMPLE RECEIVED", "PIES COLLECTION", "PIES APPROVED", "PIES REJECTED", "PM APPROVED", "PRICING", "COMPLETE"];
  var columnsToCopy = ["Status", "Start Date", "Part Type", "HOL P/N", "OE#", "ALT OE", "MAM Status (change to Dev)", "FP Status (Change to Electronically Announced)", "PartCat Status (Changed to Electronically Announced)", "Interchange", "Interchange Completion", "Parts List/RFQ Submitted to Warren", "Parts List/RFQ Returned to Holstein", "Production Sourced Part is requested from Warren", "ETA of Sample", "Date Prod Sample Delivered to Holstein", "Factory Code"];

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();

  try {
    var masterSheet = spreadsheet.getSheetByName("Consolidated Master");
    var configSheet = spreadsheet.getSheetByName("Configuration");

    // Clear existing content in Consolidated Master sheet
    masterSheet.clear();

    // Get active tab names and their statuses from the Configuration sheet
    var rangeData = configSheet.getRange("A:B").getValues();
    var activeTabs = rangeData.filter(function(row) {
      return row[1] && row[1].toLowerCase() === "active";
    }).map(function(row) {
      return row[0];
    });

    // Initialize variables
    var allData = [];
    var rowIndex = 2;

    // Insert headers
    allData.push(columnsToCopy.concat("MOQ")); // Add MOQ to the header row
    masterSheet.getRange(1, 1, 1, allData[0].length).setValues([allData[0]]);

    // Iterate through active tabs
    activeTabs.forEach(function(tabName) {
      var sheet = spreadsheet.getSheetByName(tabName);
      if (sheet) {
        var sheetData = sheet.getDataRange().getValues();

        // Get column names
        var columnNames = sheetData[1];

        // Iterate through rows (excluding header rows)
        sheetData.slice(2).forEach(function(row) {
          var status = row[0];

          // Check if status is in the list and copy relevant data
          if (statusNames.includes(status)) {
            var rowData = [status];
            columnsToCopy.forEach(function(col) {
              var colIndex = columnNames.indexOf(col);
              if (colIndex !== -1) {
                rowData.push(row[colIndex]);
              }
            });

            // Find MOQ column index and convert date to "1" if found
            var moqIndex = columnNames.indexOf("MOQ");
            if (moqIndex !== -1) {
              var moqValue = row[moqIndex];
              if (typeof moqValue === 'object' && moqValue instanceof Date) {
                rowData.push("1");
              } else {
                rowData.push(moqValue);
              }
            } else {
              rowData.push(""); // Add empty string if MOQ column not found
            }
            allData.push(rowData);
          }
        });
      }
    });

    // Insert all data at once
    if (allData.length > 1) { // Check if there's data to insert
      masterSheet.getRange(rowIndex, 1, allData.length - 1, allData[0].length).setValues(allData.slice(1));
    }
  } catch (error) {
    // Handle errors gracefully (e.g., log error or display message to user)
    console.error("Error occurred:", error);
  }
}


function updateConsolidatedRejected() {
  var statusNames = ["PIES REJECTED"];
  var columnsToCopy = ["STATUS", "Part Type", "HOL P/N", "OE#", "QC Inspection/PIES Collection", "HOL Feedback Sent", "New Sample Requested", "New Sample Received"];
 
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var masterSheet = spreadsheet.getSheetByName("Consolidated Rejected");
  var configSheet = spreadsheet.getSheetByName("Configuration");
 
  // Clear existing content in Consolidated Rejected sheet
  masterSheet.clear();
 
  // Get tab names and their statuses from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });
 
  // Initialize a variable to keep track of the row to insert data into
  var rowIndex = 2;
 
  // Insert headers for the Consolidated Rejected sheet
  var headers = columnsToCopy;
  masterSheet.getRange(1, 1, 1, headers.length).setValues([headers]);
 
  // Iterate through each active tab
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      var sheetData = sheet.getDataRange().getValues();
 
      // Get the column names from the second row
      var columnNames = sheetData[1];
 
      // Iterate through each row in the sheet
      sheetData.forEach(function(row, rowIdx) {
        if (rowIdx === 0 || rowIdx === 1) return; // Skip the header rows
 
        var status = row[0]; // Assuming status is in the first column (A)
 
        // If the status is "TERMINATED" or "PIES REJECTED", add it to the Consolidated Rejected sheet
        if (statusNames.includes(status)) {
          var rowData = [];
 
          // Insert the data into the Consolidated Rejected sheet
          columnsToCopy.forEach(function(col) {
            var colIndexInSheet = columnNames.indexOf(col);
            if (colIndexInSheet !== -1) {
              rowData.push(row[colIndexInSheet]);
            } else if (col === "STATUS") {
              rowData.push(status); // Add status directly for the STATUS column
            } else {
              rowData.push(''); // Fill in with an empty string if the column is not found
            }
          });
 
          masterSheet.getRange(rowIndex, 1, 1, rowData.length).setValues([rowData]);
          rowIndex++;
        }
      });
    }
  });
}

function synchronizeHeadersWithTemplate() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var templateSheet = spreadsheet.getSheetByName("Template Development Sheet");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Error handling for missing sheets
  if (!templateSheet) {
    SpreadsheetApp.getUi().alert('Error: "Template Development" sheet not found.');
    return;
  }
  if (!configSheet) {
    SpreadsheetApp.getUi().alert('Error: "Configuration" sheet not found.');
    return;
  }

  // Get the first two header rows from the Template Development sheet
  var templateHeaders = templateSheet.getRange(1, 1, 2, templateSheet.getLastColumn()).getValues();
  
  // Get active tab names from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });

  // Iterate through each active tab and synchronize headers
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      // Get the current headers of the active tab
      var currentHeaders = sheet.getRange(1, 1, 2, sheet.getLastColumn()).getValues();

      // Find new columns that are in the template but not in the current sheet
      var newColumns = [];
      templateHeaders[1].forEach(function(header, index) {
        if (header && !currentHeaders[1].includes(header)) {
          newColumns.push({
            header: header,
            templateColumnIndex: index
          });
        }
      });

      // If there are new columns, add them to the current sheet
      if (newColumns.length > 0) {
        newColumns.forEach(function(column) {
          var columnIndex = column.templateColumnIndex + 1; // Adjust for 1-based index in Sheets
          
          // Insert a new column at the correct position
          sheet.insertColumnBefore(columnIndex);

          // Set the new header values
          sheet.getRange(1, columnIndex, 2, 1).setValues([
            [templateHeaders[0][column.templateColumnIndex]],
            [column.header]
          ]);

          // Shift data to include the new column
          var dataRange = sheet.getRange(3, columnIndex, sheet.getLastRow() - 2, 1);
          var dataValues = dataRange.getValues();
          for (var row = 0; row < dataValues.length; row++) {
            dataValues[row][0] = ""; // Set the new column values to empty
          }
          dataRange.setValues(dataValues);
        });
      }
    }
  });
}

function synchronizeHeaderNamesWithTemplate() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var templateSheet = spreadsheet.getSheetByName("Template Development Sheet");
  var configSheet = spreadsheet.getSheetByName("Configuration");

  // Error handling for missing sheets
  if (!templateSheet) {
    SpreadsheetApp.getUi().alert('Error: "Template Development" sheet not found.');
    return;
  }
  if (!configSheet) {
    SpreadsheetApp.getUi().alert('Error: "Configuration" sheet not found.');
    return;
  }

  // Get the header rows from the Template Development sheet
  var templateHeaders = templateSheet.getRange(1, 1, 2, templateSheet.getLastColumn()).getValues();

  // Get active tab names from the Configuration sheet
  var rangeData = configSheet.getRange("A:B").getValues();
  var activeTabs = rangeData.filter(function(row) {
    return row[1] && row[1].toLowerCase() === "active";
  }).map(function(row) {
    return row[0];
  });

  // Iterate through each active tab and synchronize header names
  activeTabs.forEach(function(tabName) {
    var sheet = spreadsheet.getSheetByName(tabName);
    if (sheet) {
      // Get the current headers of the active tab
      var currentHeaders = sheet.getRange(1, 1, 2, sheet.getLastColumn()).getValues();

      // Iterate through each header in the template sheet
      templateHeaders.forEach(function(templateRow, rowIndex) {
        templateRow.forEach(function(templateHeader, columnIndex) {
          var currentHeader = currentHeaders[rowIndex][columnIndex];
          // If the header name in the template sheet is different from the header name in the active tab
          if (templateHeader !== currentHeader) {
            // Update the header name in the active tab
            sheet.getRange(rowIndex + 1, columnIndex + 1).setValue(templateHeader);
          }
        });
      });
    }
  });
}

#include <stdio.h>
#include <string.h>

enum Password_Strength
{
    TOO_WEAK,
    STRONG_ENOUGH
};

enum Password_Strength is_secure_password(char* password);

int main(void)
{
    char test_password[32];
 
    do
    {
        printf("Choose a password: \n");
        scanf("%31s", test_password);
    }
    while (is_secure_password(test_password) == TOO_WEAK);
 
    printf("%s is secure enough!\n", test_password);
 
    return 0;
}

    int is_upper(char ch)
{
    return (ch >= 'A' && ch <= 'Z');
}

int is_lower(char ch)
{
    return (ch >= 'a' && ch <= 'z');
}

int is_digit(char ch)
{
    return (ch >= '0' && ch <= '9');
}
enum Password_Strength is_secure_password(char* password)
{
    int length = strlen(password);
    int upper_count = 0;
    int lower_count = 0;
    int digit_count = 0;

    if (length < 8 || length > 12) // Minimum length requirement
    {
        return TOO_WEAK;
    }



    for (int i = 0; i < length; i++)
    {
        if (is_upper(password[i]))
            upper_count++;
        else if (is_lower(password[i]))
            lower_count++;
        else if (is_digit(password[i]))
            digit_count++;
    }

    if (upper_count >= 2 && lower_count >= 2 && digit_count >= 1)
    {
        return STRONG_ENOUGH;
    }
    else
    {
        return TOO_WEAK;
    }
 

}
{
  // This is all that matters
  "workbench.colorTheme": "Cobalt2",
  // The Cursive font is operator Mono, it's $200 and you need to buy it to get the cursive. Dank Mono or Victor Mono are good alternatives
  "editor.fontFamily": "Operator Mono, Menlo, Monaco, 'Courier New', monospace",
  "editor.fontSize": 17,
  "editor.lineHeight": 25,
  "editor.letterSpacing": 0.5,
  "files.trimTrailingWhitespace": true,
  "editor.fontWeight": "400",
  "prettier.eslintIntegration": true,
  "editor.cursorStyle": "line",
  "editor.cursorWidth": 5,
  "editor.cursorBlinking": "solid",
  "editor.renderWhitespace": "all",
}
none_of(v.begin(),v.end(),[](int x){return x>0;});
//it returns boolean value
any_of(v.begin(),v.end(),[](int x){return x%2==0;});
//it returns boolean value
all_of(v.begin(),v.end(),[](int x){return x>0;});
//it returns boolean value
it = find(v.begin(),v.end(),num);
//if not found it returns v.end();
int sum = accumulated(v.begin(),v.end(),0);
int a =*(max_element(v.begin(),v.end()));
int a =*(min_element(v.begin(),v.end()));
pair<int, int> findNonDivisiblePair(const std::vector<int>& vec) {
    for (size_t i = 0; i < vec.size(); ++i) {
        for (size_t j = i + 1; j < vec.size(); ++j) {
            if (vec[i] % vec[j] != 0 && vec[j] % vec[i] != 0) {
                return std::make_pair(vec[i], vec[j]);
            }
        }
    }
    // If no pair is found, return a pair of -1, -1 or handle as required
    return std::make_pair(-1, -1);
}
pair<int, int> findMinimumNonDivisiblePair(const std::vector<int>& vec) {
    std::pair<int, int> minPair = std::make_pair(-1, -1);
    int minSum = std::numeric_limits<int>::max();

    for (size_t i = 0; i < vec.size(); ++i) {
        for (size_t j = i + 1; j < vec.size(); ++j) {
            if (vec[i] % vec[j] != 0 && vec[j] % vec[i] != 0) {
                int currentSum = vec[i] + vec[j];
                if (currentSum < minSum) {
                    minSum = currentSum;
                    minPair = std::make_pair(vec[i], vec[j]);
                }
            }
        }
    }
    return minPair;
}
Our Customers









Imprint
bool check(vector<int>& nums) {
        int count = 0 ;
        if (nums[0] < nums[nums.size()-1]) count++ ;
        for (int i=1; i<nums.size(); i++){
            if (nums[i] < nums[i-1]){
                count++ ;
                if (count > 1) return false ;
            }
        }
        return true ;
    }
#include <iostream>

using namespace std;

int main() {
    
    char variable1 = 'b';
    int variable2 = 15;
    double variable3 = 10.2;
    
    char *pntr1 = &variable1;
    int *pntr2 = &variable2;
    double *pntr3 = &variable3;
    
    cout<<"before changing: "<<endl;
    cout<<"variable1 value= "<<variable1<<",\t\tAddress: "<<&variable1<<",\t*pntr1 value = "<<*pntr1<<endl;
    cout<<"variable2 value= "<<variable2<<",\tAddress: "<<&variable2<<",\t*pntr2 = "<<*pntr2<<endl;
    cout<<"variable3 value= "<<variable3<<",\tAddress: "<<&variable3<<",\t*pntr3 = "<<*pntr3<<endl;
    
    *pntr1 = 'c';
    *pntr2 = 25;
    *pntr3 = 12.50;
    
    cout<<"____________________"<<endl;
    cout<<"After changing: "<<endl;
    cout<<"variable1 value= "<<variable1<<",\t\tAddress: "<<&variable1<<",\t*pntr1 value = "<<*pntr1<<endl;
    cout<<"variable2 value= "<<variable2<<",\tAddress: "<<&variable2<<",\t*pntr2 = "<<*pntr2<<endl;
    cout<<"variable3 value= "<<variable3<<",\tAddress: "<<&variable3<<",\t*pntr3 = "<<*pntr3<<endl;

    
    return 0;
}
//OUTPUT:
before changing: 
variable1 value= b,		Address: b(b5��,	*pntr1 value = b
variable2 value= 15,	Address: 0x7ffce6356230,	*pntr2 = 15
variable3 value= 10.2,	Address: 0x7ffce6356228,	*pntr3 = 10.2
____________________
After changing: 
variable1 value= c,		Address: c(b5��,	*pntr1 value = c
variable2 value= 25,	Address: 0x7ffce6356230,	*pntr2 = 25
variable3 value= 12.5,	Address: 0x7ffce6356228,	*pntr3 = 12.5
body {

  margin: 0;

  background: #020202;

  cursor: crosshair;

}

canvas{display:block}

h1 {

  position: absolute;

  top: 20%;

  left: 50%;

  transform: translate(-50%, -50%);

  color: #fff;

  font-family: "Source Sans Pro";

  font-size: 5em;

  font-weight: 900;

  -webkit-user-select: none;

  user-select: none;

}
<h1>Happy Birthday</h1>

<canvas id="birthday"></canvas>
 int findMaxConsecutiveOnes(vector<int>& nums) {
        int count = 0;
        int m=0;
        int n=nums.size();
        for(int j=0;j<n;++j)
        {
            if(nums[j]==1)
            {
                count++;
                 m=max(count,m);
            }
            else{
               
                count=0;
            }
        }
        return m;
        
    }
import os
import json
import pymongo
from pymongo import MongoClient

# Configure MongoDB connection
client = MongoClient('mongodb://localhost:27017/')
db = client['twitter_db']
collection = db['tweets']

# Directory containing the JSON files
directory_path = 'C:/Users/User/Desktop/DBL Data Challenge/data'

# Function to insert JSON objects from a file into MongoDB
def insert_file(file_path):
    try:
        with open(file_path, 'r') as file:
            for line_number, line in enumerate(file, start=1):
                if line.strip():  # Skip empty lines
                    try:
                        json_object = json.loads(line)
                        document = {
                            'file_name': os.path.basename(file_path),
                            'json_data': json_object
                        }
                        collection.insert_one(document)
                    except json.JSONDecodeError as e:
                        print(f"JSONDecodeError: Error reading JSON data from file {file_path}, line {line_number}: {e}")
    except IOError as e:
        print(f"IOError: Error reading file {file_path}: {e}")
    except pymongo.errors.PyMongoError as e:
        print(f"PyMongoError: Error uploading data from file {file_path} to MongoDB: {e}")
    except Exception as e:
        print(f"Unexpected error with file {file_path}: {e}")

# Iterate over files in the directory and insert them into MongoDB
file_count = 0
error_count = 0
for filename in os.listdir(directory_path):
    file_path = os.path.join(directory_path, filename)
    if os.path.isfile(file_path) and filename.endswith('.json'):
        try:
            insert_file(file_path)
            file_count += 1
        except Exception as e:
            print(f"Unexpected error while processing file {file_path}: {e}")
            error_count += 1

print(f"All {file_count} files have been processed.")
if error_count > 0:
    print(f"There were {error_count} files that encountered errors.")
    vector<int> v;
        int n=nums.size();
        int f=k%(n);
        int a=n-f;
        for(int i=0;i<n;++i)
        {
            if((a+i)<=(n-1))
            v.push_back(nums[a+i]);
            else
            v.push_back(nums[a+i-nums.size()]);
        }
        nums=v;}
};
 if ($_FILES['file']['size'] == 0) {
          //se não existir a imagem coloa uma padrão
          $file = "assets/upload/adverts/no-photo.jpg";
        } else {

          $file = $Resources->uploadFile('assets/upload/images/adverts/', $_FILES['file']);
          if ($file == "error") {
            header("Location: " . BASE_URL . "users/advertise");
            exit;
          }
        }
public class p32_circularQ {
    public static void main(String[] args) {
        Queue q=new Queue(5);
        q.add(0);
        q.add(1);
        q.add(2);
        q.delete();
        q.add(4);
        
      
        while(!q.isEmpty()){
            System.out.println(q.peek());
            q.delete();
        }

    }

    static class Queue {
        static int arr[];
        static int size;
        static int rear;
        static int front;

        Queue(int n) {
            arr = new int[n];
            size = n;
            rear = -1;
            front=-1;
        }

        public static boolean isEmpty() {
            return rear == -1 && front==-1;
            // if(rear==-1){
            // return true;
            // }
            // return false;
        }

        public static boolean isFull(){
            return (rear+1)%size==front;
        }

        public static int delete() {
            if (rear == -1) {
                System.out.println("Empty");
                return -1;
            } 
                int temp = arr[0];
                if(rear==front){
                    rear=front=-1;
                }else{
                front=(front+1)%size;
                }
                return temp;
            
        }

        public static void add(int data) {
            if (isFull()) {
                System.out.println("Queue is full");
                return;
            } //add 1st ele
                if(front==-1){
                    front=0;
                }
                rear = (rear + 1)%size;
                arr[rear] = data;
            
        }

        public static int peek() {
            if (rear == -1) {
                System.out.println("Empty");
                return -1;
            }

            return arr[front];

        }

    }
}
 <link rel="stylesheet" href="style.css">
    <script src="script.js"></script>
 <a href = "https://www.youtube.com" target = _main>YOUTUBE</a>
 int removeDuplicates(vector<int>& nums) {
       int i=0;
       int n=nums.size();
       for(int j=1;j<n;++j)
       {if(nums[i]!=nums[j])
        {  nums[i+1]=nums[j]; i++;}}
       return i+1;}
$ cd /lib/x86_64-linux-gnu/
$ sudo ln -s libreadline.so.7.0 libreadline.so.6
 int removeDuplicates(vector<int>& nums) {
        set<int> s;
        for(int i=0;i<nums.size();++i)
        {
            s.insert(nums[i]);
        }
        set<int> :: iterator it;
        vector<int> v;
        for(it=s.begin();it!=s.end();++it)
        {
            v.push_back(*it);
        }
        nums=v;
        int a = s.size();
        return a;
        
    }
star

Sun May 26 2024 17:29:08 GMT+0000 (Coordinated Universal Time)

@signup

star

Sun May 26 2024 17:28:27 GMT+0000 (Coordinated Universal Time)

@signup

star

Sun May 26 2024 17:26:49 GMT+0000 (Coordinated Universal Time)

@signup

star

Sun May 26 2024 17:25:51 GMT+0000 (Coordinated Universal Time)

@signup

star

Sun May 26 2024 17:24:47 GMT+0000 (Coordinated Universal Time)

@signup

star

Sun May 26 2024 17:23:54 GMT+0000 (Coordinated Universal Time)

@signup

star

Sun May 26 2024 17:22:35 GMT+0000 (Coordinated Universal Time)

@signup

star

Sun May 26 2024 15:25:22 GMT+0000 (Coordinated Universal Time) https://www.facebook.com/?ref

@curtisbarry

star

Sun May 26 2024 14:12:48 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 13:44:10 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 13:23:20 GMT+0000 (Coordinated Universal Time)

@prabhas

star

Sun May 26 2024 13:22:50 GMT+0000 (Coordinated Universal Time)

@prabhas

star

Sun May 26 2024 13:20:22 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun May 26 2024 12:58:05 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 11:59:17 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 11:56:56 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 11:53:57 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 11:29:49 GMT+0000 (Coordinated Universal Time)

@taufiq_ali

star

Sun May 26 2024 10:43:42 GMT+0000 (Coordinated Universal Time)

@Mohamedshariif #c++

star

Sun May 26 2024 10:09:01 GMT+0000 (Coordinated Universal Time) https://codepen.io/wikyware-net/pen/dyKPRxQ

@ElyasAkbari #undefined

star

Sun May 26 2024 10:08:50 GMT+0000 (Coordinated Universal Time) https://codepen.io/wikyware-net/pen/dyKPRxQ

@ElyasAkbari #undefined

star

Sun May 26 2024 08:18:35 GMT+0000 (Coordinated Universal Time)

@taufiq_ali

star

Sun May 26 2024 06:45:25 GMT+0000 (Coordinated Universal Time)

@meanaspotato #c

star

Sun May 26 2024 00:39:55 GMT+0000 (Coordinated Universal Time) https://marketplace.visualstudio.com/items?itemName

@CodeMeKathy

star

Sun May 26 2024 00:35:07 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:34:27 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:33:24 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:29:30 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:22:35 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:21:30 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sun May 26 2024 00:21:01 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sat May 25 2024 22:50:54 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sat May 25 2024 22:50:05 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sat May 25 2024 22:04:42 GMT+0000 (Coordinated Universal Time) https://cloudconvert.com/about

@curtisbarry

star

Sat May 25 2024 21:26:06 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sat May 25 2024 18:36:09 GMT+0000 (Coordinated Universal Time)

@Mohamedshariif #c++

star

Sat May 25 2024 14:12:03 GMT+0000 (Coordinated Universal Time) https://codepen.io/arcs/pen/XKKYZW

@mdevil1619 #undefined

star

Sat May 25 2024 13:47:18 GMT+0000 (Coordinated Universal Time) https://codepen.io/arcs/pen/XKKYZW

@mdevil1619 #undefined

star

Sat May 25 2024 11:57:08 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Sat May 25 2024 11:50:18 GMT+0000 (Coordinated Universal Time)

@madgakantara

star

Sat May 25 2024 09:53:53 GMT+0000 (Coordinated Universal Time) https://amincode.com/html/flex-it/

@radeguzvic

star

Sat May 25 2024 07:30:40 GMT+0000 (Coordinated Universal Time) https://medium.com/@dmktg9.singhal/the-manufacturing-process-of-pp-woven-fabric-a-comprehensive-guide-ea40bf83523f

@Singhalglobal

star

Fri May 24 2024 22:47:51 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Fri May 24 2024 20:14:55 GMT+0000 (Coordinated Universal Time)

@jdeveloper #php

star

Fri May 24 2024 16:27:52 GMT+0000 (Coordinated Universal Time)

@Farhana

star

Fri May 24 2024 15:02:13 GMT+0000 (Coordinated Universal Time)

@AYWEB #html

star

Fri May 24 2024 15:00:33 GMT+0000 (Coordinated Universal Time)

@AYWEB #html

star

Fri May 24 2024 14:13:44 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

star

Fri May 24 2024 13:58:40 GMT+0000 (Coordinated Universal Time)

@rogueta #bash

star

Fri May 24 2024 12:41:03 GMT+0000 (Coordinated Universal Time)

@ayushg103 #c++

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension