1520. Maximum Number of Non-Overlapping Substrings

Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions: The substrings do not overlap, that is for any two substrings s[i..j] and s[x..y], either j < x or i > y is true. A substring that contains a certain character c must also contain all occurrences of c. Find the maximum number of substrings that meet the above conditions. If there are multiple solutions with the same number of substrings, return the one with minimum total length. It can be shown that there exists a unique solution of minimum total length. Notice that you can return the substrings in any order.
/**
 * @param {string} s
 * @return {string[]}
 */
var maxNumOfSubstrings = function(s) {
    const n = s.length;
    const first = Array(26).fill(n);
    const last = Array(26).fill(-1);

    // Step 1: first/last occurrence
    for (let i = 0; i < n; i++) {
        let idx = s.charCodeAt(i) - 97;
        first[idx] = Math.min(first[idx], i);
        last[idx] = Math.max(last[idx], i);
    }

    const intervals = [];

    // Step 2: expand intervals
    for (let c = 0; c < 26; c++) {
        i

IELTS Speaking part Set 1 Test 1

Part 2

useful and practical one
- spasious but compact (parking)
- gas consumtion and preis
- reliable new vs fancy

must have:
- air conditioner
- automatic gear box
nice to have
- rear camera
- parking sensors

daily life
- drive to my work
- drive to the supermarket
holiday across europe
- austria (mountains
- beach south france or italy
- visit my parents in poland

Part 3
Topic 1
+ flexibilty
+ enjoy driving
- costs
- need parking space

don't generilise, depends on how busy the city centr

wordpressの「改ページ(ページ送り)」の出力

wp_link_pages()を使用してコンテンツにページネーションを追加させる。 この時、ループを通さないと wp_link_pages() は常に「1ページしかない」と判断し、リンクが出力されないので注意
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
		<?php the_content(); ?>
		<?php wp_link_pages(); ?>
<?php endwhile;

Conteo de productos validos

SELECT DISTINCT UP.cveProducto
FROM U_PRODUCTO UP
	INNER JOIN ATRIBUTOS_PRODUCTO_AMAZON APA
		ON APA.cveProducto = UP.cveProducto
	INNER JOIN SUCURSAL_STOCK SS
		ON SS.cveProducto = UP.cveProducto
WHERE UP.cveLinea = 8
	AND UP.urlImagen NOT LIKE '%NotFound.webp%'
	AND SS.cveSistema = '0'
	AND SS.cveSucursal = '001'
	AND SS.stock > 0
	AND EXISTS (
		SELECT cveProducto, COUNT(*) 
		FROM ATRIBUTOS_PRODUCTO_AMAZON 
		GROUP BY cveProducto 
		HAVING COUNT(*) > 1
	)

Verificar Stock

SELECT * 
FROM SUCURSAL_STOCK SS
WHERE SS.cveProducto = 'VS-3245-R'
	AND SS.cveSistema = '0'
	AND SS.cveSucursal = '001'

1477. Find Two Non-overlapping Sub-arrays Each With Target Sum

You are given an array of integers arr and an integer target. You have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum. Return the minimum sum of the lengths of the two required sub-arrays, or return -1 if you cannot find such two sub-arrays.
/**
 * @param {number[]} arr
 * @param {number} target
 * @return {number}
 */
var minSumOfLengths = function(arr, target) {
    const n = arr.length;
    // minLen[i] stores the minimum length of a valid sub-array ending at or before index i
    const minLen = new Array(n).fill(Infinity);
    
    let left = 0;
    let currentSum = 0;
    let minWindowLen = Infinity;
    let ans = Infinity;
    
    for (let right = 0; right < n; right++) {
        currentSum += arr[right];
        
        // 

POP Pull

A better advect by volume wrangle than the default node. Replicates the "pull" style of force injection seen in the volume source node and has a minimum threshold so that particles outside the velocit yvolume bounds don't get stuck.
// Sampling
vector curr_v = v@v;
vector vol_v = volumesamplev(1, "vel", v@P);
vol_v *= chf("scale_force");

// Speeds
float curr_speed = length(curr_v);
float vol_speed = length(vol_v);

// Directional vectors
vector curr_dir = normalize(curr_v);
vector vol_dir = normalize(vol_v);

// Weights
float weight_v = 1;
float weight_v_dir = weight_v;

float weight_vol = 0;
if (curr_speed < vol_speed) weight_vol = chf("acceleration");
if (curr_speed > vol_speed) weight_vol = chf("decel

JSON CPP Example

// const auto hwRev = readHwRevConfig(platformData, hwRevMapPath);
const std::string hwRevStr = R"(
    {
        "description": "2 drivers xxxxx | xxxxx lighting",
        "maxIspGainDay": 8192,
        "backlightDrivers": {
            "driverVer": 1,
            "selectorGpio": {
                "switch": { "lineNum": 110 }
            },
            "pwm": {
                "irGroup": { "chip": 5, "line": 0, "periodUs": 250, "dutyCycleLowLimit": 50000, "dutyCycleHighLimit": 90000 },
        

1621. Number of Sets of K Non-Overlapping Line Segments

Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment covers two or more points. The endpoints of each segment must have integral coordinates. The k line segments do not have to cover all n points, and they are allowed to share endpoints. Return the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.
/**
 * @param {number} n
 * @param {number} k
 * @return {number}
 */
const MOD = 1_000_000_007;

// Fast exponentiation: computes (a^b) % MOD
function modPow(a, b) {
    let res = 1n;
    let x = BigInt(a);
    let exp = BigInt(b);

    while (exp > 0n) {
        // If lowest bit is 1, multiply result by current base
        if (exp & 1n) {
            res = (res * x) % BigInt(MOD);
        }
        // Square the base each step
        x = (x * x) % BigInt(MOD);
        exp >>= 1n; // shift ri

Cancel Cacher User's Membership

1.  Impersonate user: 
[https://snippets.cacher.io/snippet/b61256b4da1f7d0c502e](https://snippets.cacher.io/snippet/b61256b4da1f7d0c502e)
2.  Actually cancelling the membership:
[https://snippets.cacher.io/snippet/564dd9780d6096e06cba](https://snippets.cacher.io/snippet/564dd9780d6096e06cba)

2472. Maximum Number of Non-overlapping Palindrome Substrings

You are given a string s and a positive integer k. Select a set of non-overlapping substrings from the string s that satisfy the following conditions: The length of each substring is at least k. Each substring is a palindrome. Return the maximum number of substrings in an optimal selection. A substring is a contiguous sequence of characters within a string.
/**
 * @param {string} s
 * @param {number} k
 * @return {number}
 */
var maxPalindromes = function(s, k) {
    const n = s.length;
    const intervals = [];

    const tryCenter = (l, r) => {
        while (l >= 0 && r < n && s[l] === s[r]) {
            if (r - l + 1 >= k) {
                intervals.push([l, r]);
                return; // <-- CRITICAL: stop after first valid palindrome
            }
            l--; r++;
        }
    };

    for (let i = 0; i < n; i++) {
        tryCenter(i

IELTS_5_Practice_test_Set_4_Test_18_Listening

Watson
16
1996
Dental assistant
388
fight bars
website
10:00
induction
personal trainer
A
C
F
H
J
B
F
I
J
M
secondary visit
source
flow levels
archives 
rolle
A
B
A
C
B
fear



habitants
disturbance
dominance

gram
captivity


836. Rectangle Overlap

An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis. Two rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap. Given two axis-aligned rectangles rec1 and rec2, return true if they overlap, otherwise return false.
/**
 * @param {number[]} rec1
 * @param {number[]} rec2
 * @return {boolean}
 */
var isRectangleOverlap = function(rec1, rec2) {
    // If one rectangle is completely to one side of the other, no overlap
    if (rec1[2] <= rec2[0] ||  // rec1 right <= rec2 left
        rec1[0] >= rec2[2] ||  // rec1 left >= rec2 right
        rec1[3] <= rec2[1] ||  // rec1 top <= rec2 bottom
        rec1[1] >= rec2[3]) {  // rec1 bottom >= rec2 top
        return false;
    }
    return true;
};

Get Stats Info

Виводить вагу БД, кількість сайтів, постів і сторінок мультисайту
SET SESSION group_concat_max_len = 1000000;

SET @db = 'gambling1';

-- Генеруємо підзапити для всіх wp*_posts таблиць Multisite
SELECT GROUP_CONCAT(
               CONCAT(
                       'SELECT ',
                       'COUNT(CASE WHEN post_type = ''post'' THEN 1 END) AS posts, ',
                       'COUNT(CASE WHEN post_type = ''page'' THEN 1 END) AS pages ',
                       'FROM `', table_schema, '`.`', table_name, '` ',
                       'WHERE post_type IN (''post

835. Image Overlap

You are given two images, img1 and img2, represented as binary, square matrices of size n x n. A binary matrix has only 0s and 1s as values. We translate one image however we choose by sliding all the 1 bits left, right, up, and/or down any number of units. We then place it on top of the other image. We can then calculate the overlap by counting the number of positions that have a 1 in both images. Note also that a translation does not include any kind of rotation. Any 1 bits that are translated outside of the matrix borders are erased. Return the largest possible overlap.
/**
 * @param {number[][]} img1
 * @param {number[][]} img2
 * @return {number}
 */
var largestOverlap = function(img1, img2) {
    const n = img1.length;
    const A = [];
    const B = [];

    // Collect coordinates of 1s
    for (let r = 0; r < n; r++) {
        for (let c = 0; c < n; c++) {
            if (img1[r][c] === 1) A.push([r, c]);
            if (img2[r][c] === 1) B.push([r, c]);
        }
    }

    const map = new Map();
    let max = 0;

    // Count translation vectors
    for 

3414. Maximum Score of Non-overlapping Intervals

You are given a 2D integer array intervals, where intervals[i] = [li, ri, weighti]. Interval i starts at position li and ends at ri, and has a weight of weighti. You can choose up to 4 non-overlapping intervals. The score of the chosen intervals is defined as the total sum of their weights. Return the lexicographically smallest array of at most 4 indices from intervals with maximum score, representing your choice of non-overlapping intervals. Two intervals are said to be non-overlapping if they do not share any points. In particular, intervals sharing a left or right boundary are considered overlapping.
/**
 * @param {number[][]} intervals
 * @return {number[]}
 */
var maximumWeight = function(intervals) {
    const n = intervals.length;

    // augment with original index
    let arr = intervals.map((it, i) => ({ l: it[0], r: it[1], w: it[2], idx: i }));

    // sort by end time, then start
    arr.sort((a, b) => a.r - b.r || a.l - b.l);

    // precompute prev[i]: last j with arr[j].r < arr[i].l
    const rights = arr.map(x => x.r);
    const prev = Array(n).fill(-1);
    for (let i = 0; i <