Maximizing Final Score in a Custom Jeopardy Game with Doubling Questions

In this problem, there are n questions with given point values and m special questions that allow doubling the current score instead of earning their base points. The goal is to arrange the order of answering all questions so that the final score is maximized. Each question i has a fixed value val[i]. Among them, m indices correspond to doublin ...

Posted on Mon, 08 Jun 2026 16:10:56 +0000 by lorddraco98

Dynamic Programming: Solving Multi-State Problems

The Massage Therapist Scheduling Problem Problem link: https://leetcode.cn/problems/the-masseuse-lcci/ A renowned massage therapist receives a continuous stream of appointment requests. Each appointment can be accepted or declined. Due to the need for rest periods between sessions, she cannot accept consecutive appointments. Given a sequence of ...

Posted on Sat, 30 May 2026 19:39:23 +0000 by stelthius

Dynamic Programming Fundamentals and Applications

Linear DP Core Concepts Dynamic Programming (DP) solves complex problems by breaking them in to overlapping subproblems. The solution to the main problem is derived from solutions to these subproblems. State Representation State are typically represented as dp[i][j] = value, where i and j are indices or variables describing the state, and value ...

Posted on Thu, 28 May 2026 20:03:56 +0000 by d3ad1ysp0rk

Foundations of Deep Learning: From Nearest Neighbors to Transformers

Nearest Neighbor and k-NN Classifiers The Nearest Neighbor classifier stores the entire training set and predicts labels by finding the closest training example using a distance metric like L1 (Manhattan) or L2 (Euclidean). While simple, it suffers from high prediction latency (O(n)) and large memory usage. class KNearestNeighbor: def init(sel ...

Posted on Mon, 25 May 2026 19:10:33 +0000 by suigion

Solving the 0/1 Knapsack Problem Using Genetic Algorithms in MATLAB

The 0/1 Knapsack problem is a classic combinatorial optimization challenge. Given a set of items, each with a specific weight $w_i$ and value $v_i$, the goal is to determine wich items to include in a collection so that the total weight does not exceed a predefined limit $W$, while the total value is maximized. This is mathematically expressed ...

Posted on Fri, 22 May 2026 17:39:44 +0000 by GoSharks

Dynamic Programming: Core Concepts and Algorithmic Implementations

Understanding Dynamic Programming Dynamic programming (DP) is an optimization technique used to solve complex problems by breaking them into simpler subproblems. It stores the results of subproblems to avoid redundant computations, thereby improving efficiency. This article explores fundamental DP concepts and implementations through various al ...

Posted on Wed, 20 May 2026 00:48:10 +0000 by saint959

Database Optimization and Core Concepts

Database Fundamentals A database is essentially a file system designed for data storage, composed of file systems and disk storage. Each I/O operation involves seek time and rotational latency. 1. Database Design Principles E-R Model Modern physical databases are designed using the Entity-Relationship model: E represents entities R represents ...

Posted on Tue, 19 May 2026 14:20:25 +0000 by wolf

Maximum Bitwise OR After K Doubling Operations

Problem Statement Given a integer array nums of length n (0-indexed) and an integer k, you may perform the following operation at most k times: Select any element and multiply it by 2 Return the maximum value of nums[0] | nums[1] | ... | nums[n - 1], where a | b denotes the bitwise OR operation. Examples: Example 1: Input: nums = [12,9], k = ...

Posted on Mon, 18 May 2026 21:53:55 +0000 by opels

Optimizing Number Theory and Graph Algorithms for Competitive Programming

Efficient XOR Sum Calculation Define (f(i) = \oplus_{d|i}d), then compute (\oplus_{i=1}^{n}f(i)) for (n \le 10^{14}). Approach: Count occurrences of each number via floor division blocks and compute interval XOR sums. #include <bits/stdc++.h> using namespace std; using ll = long long; ll prefix_xor(ll x) { if (!x) return 0; ll re ...

Posted on Mon, 18 May 2026 21:50:34 +0000 by lilRachie

Optimizing Minimum Perfect Square Sum with Dynamic Programming

Problem Statement Given a positive integer n, determine the smallest number of perfect squares that sum to n. A perfect square is an integer equal to the square of another integer — for example, 1, 4, 9, and 16 are perfect squares; 3 and 11 are not. Naive Recursiev Approach A top-down recursive solution defines minSquares(x) as the minimum coun ...

Posted on Sun, 17 May 2026 15:42:01 +0000 by neonorange79