This week's #cprogramming lesson continues my exploration of the C language ctype functions (also found in other programming languages). The topic today covers isupper() and islower(), along with alternatives for detecting upper and lowercase ASCII text. https://lnkd.in/g5v7U-CM
C Programming: ctype Functions isupper() and islower()
More Relevant Posts
-
🧠 Day 248— Count Special Characters II 🔤📚 Today solved a string processing problem using: character tracking + indexing logic. 📌 Problem Goal Given a string, count characters where: ✔️ lowercase letter appears first ✔️ uppercase version appears later Example: → 'a' before 'A' → valid special character 🔹 Core Idea Track the latest position of lowercase characters first. Then while traversing: → if uppercase character appears AFTER its lowercase → count it as special 🔹 Approach Thinking 1️⃣ Store Lowercase Positions Create an array for: → latest occurrence of each lowercase letter This helps quickly check: “Did lowercase appear before uppercase?” 2️⃣ Traverse Again For every uppercase character: → convert to lowercase index → check stored lowercase position If: ✔️ lowercase exists ✔️ uppercase comes later → increment answer 3️⃣ Prevent Double Counting After counting a character once: → mark it invalid/reset So duplicate uppercase letters don’t increase answer again. 🧠 Key Learning ✔️ Character indexing makes string problems efficient ✔️ ASCII transformations are very powerful: → toLowerCase() → toUpperCase() ✔️ Arrays are often faster than HashMaps for fixed alphabets. 💡 Today’s Realization This problem connects with: Character frequency problems String hashing concepts Case conversion logic Index tracking patterns Main idea: → preprocess information first, → then validate conditions efficiently. 🚀 Momentum Status: String problem-solving becoming faster and cleaner. On to Day 249. #DSA #Strings #Arrays #LeetCode #Java #ProblemSolving #CodingJourney #ConsistencyWins
To view or add a comment, sign in
-
-
LeetCode POTD | Day 59 3121. Count the Number of Special Characters II Today’s problem was another character tracking problem, but this time with stricter position conditions between lowercase and uppercase letters. We had to count characters where all lowercase occurrences appeared before the uppercase occurrence. My approach: • Used a HashMap<Character, Integer> to store character positions • Traversed the string from right to left • Stored uppercase character indices directly • For lowercase characters, stored the maximum index using Math.max() • Iterated through all 26 characters and compared lowercase and uppercase positions • Increased the count only when the lowercase position appeared before the uppercase position Using reverse traversal simplified the index handling logic and made the comparisons much cleaner. What I learned today: • Traversal direction can completely simplify a problem • HashMaps are very useful for index-based character tracking • Position-based string problems require careful condition checking • Small optimizations in logic can make implementations cleaner • Character problems become easier once patterns are identified #LeetCode #DSA #Strings #HashMap #Java #ProblemSolving #CodingJourney #Algorithms #LeetCodeDailyChallenge
To view or add a comment, sign in
-
-
🚀 LeetCode Daily Challenge 🔗 Problem: https://lnkd.in/dGC2Q2G4 This solution counts "special" characters in a string. A character is special if it appears in both lowercase and uppercase forms within the word. A vector of 26 pairs is set up, one for each letter of the alphabet. Each pair contains two booleans. The first boolean tracks if the lowercase version of the letter has been seen, and the second tracks if the uppercase version has been seen. Both start as false. The loop goes through each character in the input string. If the character is lowercase (ASCII value >= 'a'), it calculates the alphabet index using ch - 'a' and sets the first boolean in that slot to true. If the character is uppercase, it calculates the index using ch - 'A' and sets the second boolean to true. Both 'a' and 'A' map to index 0, 'b' and 'B' to index 1, and so on. This connects the tracking of lowercase and uppercase letters under the same slot. After finishing the first loop, a second loop checks all 26 slots. If both booleans in a slot are true, it indicates that the letter appeared as both lowercase and uppercase at least once, making it special. The counter is then increased. The function returns the final count of special characters. 👉 My Solution: https://lnkd.in/dEY5RndW If you found this helpful, feel free to ⭐ the repo or connect! 🙂 #️⃣ #leetcode #cpp #dsa #coding #problemsolving #engineering
To view or add a comment, sign in
-
-
Day 32 of 2021 days. POTD 3D Dynamic Programming. Cost, score # PROBLEM: 3742. Maximum Path Score in a Grid It was quite intuitive what to apply when you are familiar with dp basic + intermediate concepts : ) #SOLUTION: class Solution: def maxPathScore(self, grid: List[List[int]], k: int) -> int: m, n = len(grid), len(grid[0]) # why k + 1? dp = [[[-float('inf')] * (k + 1) for _ in range(n)] for _ in range(m)] # base case start_cost = 0 if grid[0][0] == 0 else 1 start_score = grid[0][0] if start_cost <= k: dp[0][0][start_cost] = start_score for i in range(m): for j in range(n): cell_cost = 0 if grid[i][j] == 0 else 1 cell_score = grid[i][j] for c in range(cell_cost, k + 1): if i > 0 and dp[i - 1][j][c-cell_cost] != -float('inf'): dp[i][j][c] = max(dp[i][j][c], dp[i - 1][j][c-cell_cost] + cell_score) if j > 0 and dp[i][j - 1][c - cell_cost] != -float('inf'): dp[i][j][c] = max(dp[i][j][c], dp[i][j - 1][c - cell_cost] + cell_score) print(f"dp: {dp[m - 1][n - 1]}") ans = max(dp[m - 1][n - 1]) return ans if ans != -float('inf') else -1 # m = len(grid) # n = len(grid[0]) # dp = [[0] * n for _ in range(m)] # # base case # dp[0][0] = grid[0][0] # for j in range(1, n): # dp[0][j] = dp[0][j - 1] + grid[0][j] # for i in range(1, m): # dp[i][0] = dp[i - 1][0] + grid[i][0] # for i in range(1, m): # for j in range(1, n): # dp[i][j] = grid[i][j] + max(dp[i - 1][j], dp[i][j - 1]) # if dp[m - 1][n - 1] <= k: # return dp[m - 1][n - 1] # return - 1 #SoftwareEngineering #SystemDesign #Algorithms #ProblemSolving #BackendDevelopment
To view or add a comment, sign in
-
🚀Python Practice Update ✅ Solved the Set .discard(), .remove() & .pop()challenge on HackerRank ✅ Practiced Python set operations ✅ Learned the difference between `discard()`, `remove()`, and `pop()` ✅ Improved understanding of modifying set elements ✅ Strengthened Python problem-solving skills 💻 Learning Python step by step through daily practice. 🔗Link: https://lnkd.in/dg6UY9dP #Python #HackerRank #PythonSets #SetOperations #CodingPractice #ProblemSolving #100DaysOfCode #PythonProgramming #LearningPython #CompetitiveProgramming
To view or add a comment, sign in
-
LeetCode POTD | Day 58 3120. Count the Number of Special Characters I Today’s problem was based on character tracking and set operations. We had to count how many characters appeared in both lowercase and uppercase forms inside the string. My approach: • Used a HashSet<Character> to keep track of visited characters • Traversed the string character by character • Checked whether the opposite case version of the current character already existed in the set • If both lowercase and uppercase versions were present, increased the count • Added every processed character into the set for future checks The ASCII-based case conversion made the implementation shorter and efficient without needing extra helper functions. What I learned today: • Sets are extremely useful for fast character lookup • ASCII operations can simplify character conversion logic • Small string problems still require careful condition handling • Keeping the solution simple often leads to cleaner code • Character manipulation problems become easier with pattern observation #LeetCode #DSA #Strings #HashSet #Java #ProblemSolving #CodingJourney #Algorithms #LeetCodeDailyChallenge
To view or add a comment, sign in
-
-
Did you know .append() in c++ can secretly read random memory on your machine? My code compiled perfectly. The data was completely wrong. And I spent 3 days figuring out why. I was working with QByteArray in Qt, storing some sensor values. Simple stuff. I wrote: ba.append(val); // val is a double Ran the code. The data looked completely wrong — like random garbage characters. I stared at it for 3 days thinking, did I pass the wrong variable? Is there a memory corruption somewhere? Is it a hardware issue? Nope. The culprit was the compiler — and it didn't even apologize. Here's the story of what happened behind the scenes: The compiler received a double and went looking for a matching append() overload. It searched... and found nothing for double. But instead of throwing an error, the compiler thought — "let me just find the closest thing I can work with." And it found append(const char*). So it did something perfectly legal by C++ rules — it took the raw bit pattern of the double value and treated it as a memory address. A pointer. Then it marched to that address and started reading bytes from there. No error. No warning. Just silently reading random memory and stuffing it into my QByteArray. This is called implicit conversion — and it is one of the most silent killers in C++. After 3 days of head scratching, I tried the old school way: ar[i] = val; And everything worked perfectly. Why? Because the [] operator doesn't go through this overload resolution circus. It directly assigns the value to that position — no guessing, no implicit casting, no surprises. 3 days. One line. Biggest lesson of my C++ journey so far. The compiler is not your enemy — but it will always find a way to compile your code, even if what it compiles is not what you meant. If you are working with C++, always compile with -Wall -Wextra. Make the compiler speak up before it silently wrecks your data and your weekend. #CPlusPlus #Qt #Debugging #ProgrammingTips #SoftwareDevelopment #TodayILearned
To view or add a comment, sign in
-
I just released #Syntalos 3.0.0 for all your #scientific data acquisition needs on #Linux! The release contains major breaking changes that may require adjustments for existing projects and will require adjustments to external modules, alongside tons of new features, UI and performance improvements. Highlights: * Network control: Syntalos can now control, or be controlled by, other Syntalos instances over the network - enabling synchronized runs across a fleet of machines * New modules: A "Zarr Writer" for writing #Zarr v3 array stores, a "Prism" module to split / merge / drop image color channels, and an experimental preview module for the #OpenEphys data acquisition board. * Rewritten IPC framework, now based on #iceoryx2 instead of iceoryx1 * Memory: Syntalos now uses the #mimalloc allocator internally, reducing memory use and improving throughput in heavily-threaded paths. * Stream type casting: Compatible data streams (e.g. uint16 matrices into int32) can now be connected directly; the UI shows a cast indicator. * Human-friendly recording monikers: In addition to the unique recording ID, Syntalos can produce a short, human-readable name for each run. Enable it in the project settings. * Plot & canvas: The time-series plot has drastically faster rendering, and the image canvas now supports native 16-bit display. * All public APIs now no longer use Qt, making it a lot easier to bind custom software to Syntalos as a module. Detailed changes are listed here: https://lnkd.in/dtsb6ATE We have a small porting guide to help porting 2.x projects to 3.0: https://lnkd.in/dfSxrpXE You can learn more about this #OpenSource project and download it here: https://syntalos.org/ Thanks to all testers and contributors who helped with this release, and/or hired me to implement bespoke features! It is a huge milestone with more than 400 individual changes based on the feedback of (neuro)scientists, who can now run their experiments easier 😀
To view or add a comment, sign in
-
#DSAChallengeDay53 Today’s challenge was a neat exercise in bit manipulation + set intersection logic 🔠⚡ 📌 Problem Solved Today (LeetCode - 3120): Count the Number of Special Characters I ✅ Logic: The task is to count characters that appear in both lowercase and uppercase in the string. I solved this using bit manipulation for efficient tracking: ✅ Traversed the string and tracked lowercase characters using a bitmask ✅ Tracked uppercase characters using a separate bitmask ✅ Used bitwise AND (lower & upper) to find common characters ✅ Counted set bits using Integer.bitCount() to get the final answer 💡 Learnings: 🔹 Bit manipulation is a powerful way to optimize space and speed for character tracking 🔹 Using bitmasks avoids extra data structures like sets/maps 🔹 The intersection of two bitmasks directly gives the required result 🔹 Efficient solution with O(n) time and O(1) space 🚀 This problem reinforced how low-level techniques like bit operations can simplify seemingly straightforward problems and make solutions more elegant. #DSAChallengeDay53 #100DaysOfDSA #LeetCode #LeetCodeDailyChallenge #BitManipulation #Java #DSA #CodingJourney #KeepCoding #OptimizationTricks #geekstreak2025 #personalguidanceprogram #pgpbyanchal
To view or add a comment, sign in
-
-
𝗧𝗢𝗣𝗜𝗖: 𝗦𝗧𝗥𝗜𝗡𝗚𝗦 📌𝗪𝗵𝗮𝘁 𝗮𝗿𝗲 𝗦𝘁𝗿𝗶𝗻𝗴𝘀 𝗶𝗻 𝗖❓ Strings in C are collections of characters stored inside an array and terminated with a special character called the null character ('\0'). 👉 In simple words, a string is used to store text like names, messages, or sentences in a program. Example: char name[] = "Hello"; Memory representation: H e l l o \0 The '\0' tells the compiler where the string ends. 📌𝗪𝗵𝘆 𝗹𝗲𝗮𝗿𝗻 𝗦𝘁𝗿𝗶𝗻𝗴𝘀❓ Strings are one of the most important concepts in programming because many real-world applications work with text data. 👉 One simple reason to learn strings: They help you process, store, compare, and manipulate text efficiently in programs. Strings are widely used in: ✔ Login systems ✔ Chat applications ✔ File handling ✔ Search engines ✔ Embedded systems ✔ Data processing 📌𝗕𝗮𝘀𝗶𝗰 𝗦𝘁𝗿𝗶𝗻𝗴 𝗗𝗲𝗰𝗹𝗮𝗿𝗮𝘁𝗶𝗼𝗻𝘀 🔸 Using array char str[20] = "Hello"; 🔸 Character by character char str[] = {'H','e','l','l','o','\0'}; 🔸 Using pointer char *str = "Hello"; 📌𝗖𝗼𝗺𝗺𝗼𝗻 𝗦𝘁𝗿𝗶𝗻𝗴 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀 𝗶𝗻 𝗖 👉 These functions are available in: #include <string.h> 🔸 strlen() → Finds string length 🔸 strcpy() → Copies one string to another 🔸 strcat() → Joins two strings 🔸 strcmp() → Compares two strings 🔸 strchr() → Searches a character in string 🔸 strstr() → Searches a substring 📌𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝗣𝗼𝗶𝗻𝘁𝘀 𝗔𝗯𝗼𝘂𝘁 𝗦𝘁𝗿𝗶𝗻𝗴𝘀 🔸 Strings always end with '\0' 🔸 String indexing starts from 0 🔸 Strings are stored in contiguous memory locations 🔸 A string is actually a character array in C 📌𝗘𝘅𝗮𝗺𝗽𝗹𝗲 𝗪𝗼𝗿𝗸𝗳𝗹𝗼𝘄 vi string's → opens source file gcc string.c → compiles program ./a.out → runs program 👉 Strings are one of the most powerful topics in C programming. The more you practice string problems, the stronger your programming logic becomes. #CProgramming #Strings #Programming #Coding #SoftwareDevelopment #EmbeddedSystems #Linux #ComputerScience #Developers #Learning #EmbeddedC
To view or add a comment, sign in
Good tip! Thanks Dan