5 posts about Modular Arithmetic by 1 contributor.
Know Modular Arithmetic? Share what you know with developers who are learning it.
Learn how to count array subsets whose MEX falls within a given range using frequencies, powers of two, and modular arithmetic in Java.
Learn how to count palindromic strings of length up to n using the first k lowercase English letters, where no character appears more than twice. This article explains the key palindrome observations, separates even and odd-length cases, derives the permutation formulas, and provides an efficient Java solution using modular arithmetic. The solution achieves O(k) time complexity and O(1) auxiliary space.
Count Subsequences Divisible by N is a Dynamic Programming problem where we need to count the number of non-empty subsequences of a numeric string whose numeric value is divisible by a given integer n. The solution uses remainder-based DP to efficiently track subsequences for each possible remainder instead of generating all subsequences. The approach runs in O(|s| × n) time and O(n) space and handles large inputs efficiently.
Find the last digit of a^b for huge numbers. Learn about cyclicity of last digits and efficient modulo operations for large exponents.
Master the Josephus Problem! Learn the elegant recurrence relation, its 0-based and 1-based solutions, and why iterative is superior.
DevSocialUpcoming · 3rd editionAI Agents ConferenceNov 23–27, 2026Live onlineMembers only17days leftRegisterPublish an article in this category and earn +1,000 SHARP when it is approved.
Write an article