How to Check if Digits Are Equal in a String After Operations (LeetCode 3461)

📌 Day 33/100 – Check If Digits Are Equal in String After Operations (LeetCode 3461) 🔹 Problem: Given a string s consisting of digits, repeatedly replace it by a new string formed by taking the sum (mod 10) of every pair of adjacent digits until only two digits remain. Return true if the final two digits are the same, otherwise false. 🔹 Approach: Iteratively built a new string using adjacent digit sums modulo 10. Repeated the process until the string length reduced to 2, then compared the final digits. Used StringBuilder for efficient construction of intermediate strings. 🔹 Key Learning: Reinforced clean looping and string handling patterns in Java. 🔹 Complexity: Time: O(n²) — Each iteration processes a smaller string. Space: O(n) for intermediate string storage. #100DaysOfCode #LeetCode #Java #StringManipulation #DSA #ProblemSolving #CodingPatterns #Iteration #ModularArithmetic

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories