✅ Day 68 of 100 Days LeetCode Challenge Problem: 🔹 #1207 – Unique Number of Occurrences 🔗 https://lnkd.in/g2vjwwft Learning Journey: 🔹 Today’s problem required checking whether the frequency of each element in an array is unique. 🔹 I first used Counter to count how many times each number appears in the array. 🔹 Then I extracted the occurrence counts using .values(). 🔹 To verify uniqueness, I compared the length of the occurrences list with the length of a set created from those values. 🔹 If both lengths match, it means all occurrence counts are unique. Concepts Used: 🔹 Hash Map / Frequency Counting 🔹 Python Counter from collections 🔹 Sets for Uniqueness Check Key Insight: 🔹 Converting values to a set removes duplicates automatically. 🔹 If the size of the set equals the number of frequency values, then all occurrence counts are distinct. Complexity: 🔹 Time: O(n) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
Unique Number Occurrences in Array with Python
More Relevant Posts
-
✅ Day 70 of 100 Days LeetCode Challenge Problem: 🔹 #1051 – Height Checker 🔗 https://lnkd.in/g7bmj62W Learning Journey: 🔹 Today’s problem required identifying how many students are not standing in the correct order according to their heights. 🔹 I first created a sorted version of the heights array to represent the expected order. 🔹 Then I compared each element of the original list with the corresponding element in the sorted list. 🔹 Every mismatch indicates a student standing in the wrong position, so I incremented a counter for each difference. Concepts Used: 🔹 Sorting 🔹 Array Comparison 🔹 Iteration Key Insight: 🔹 Instead of rearranging elements, simply comparing the original array with its sorted version reveals how many indices differ. 🔹 Each mismatch directly contributes to the final count. Complexity: 🔹 Time: O(n log n) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
✅ Day 92 of 100 Days LeetCode Challenge Problem: 🔹 #2011 – Final Value of Variable After Performing Operations 🔗 https://lnkd.in/gX-JQNUJ Learning Journey: 🔹 Today’s problem was about evaluating a sequence of increment and decrement operations. 🔹 I initialized a variable ans = 0 to track the value. 🔹 Used a hashmap to map each operation to its effect: • "++X" and "X++" → +1 • "--X" and "X--" → -1 🔹 Iterated through the operations and updated ans accordingly. 🔹 Returned the final computed value. Concepts Used: 🔹 HashMap / Dictionary 🔹 String Matching 🔹 Simple Simulation Key Insight: 🔹 Instead of using multiple condition checks, mapping operations to values simplifies logic and improves readability. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
🚀 30 𝐃𝐚𝐲𝐬 𝐨𝐟 𝐏𝐲𝐭𝐡𝐨𝐧 — 𝐃𝐚𝐲 #20 | 𝐃𝐞𝐞𝐩 𝐃𝐢𝐯𝐞 𝐢𝐧𝐭𝐨 𝐒𝐭𝐫𝐢𝐧𝐠𝐬 & 𝐌𝐞𝐭𝐡𝐨𝐝𝐬 Day 20 was all about going deeper into strings and string methods to build a stronger conceptual understanding. Instead of practicing questions, I focused on understanding how strings work internally and how different methods can be used to manipulate text efficiently. 📌 𝐖𝐡𝐚𝐭 𝐈 𝐂𝐨𝐯𝐞𝐫𝐞𝐝: 🔹 Strengthened my understanding of strings 🔹 𝐬𝐩𝐥𝐢𝐭() — breaking strings into parts 🔹 𝐣𝐨𝐢𝐧() — combining elements into a string 🔹 𝐟𝐢𝐧𝐝() — locating substrings 🔹 𝐫𝐞𝐩𝐥𝐚𝐜𝐞() — modifying text 🔹 Explored multiple other useful 𝐬𝐭𝐫𝐢𝐧𝐠 𝐦𝐞𝐭𝐡𝐨𝐝𝐬 This deeper dive helped me understand how Python handles text data and how these methods are used in real-world scenarios. 💡 𝑲𝒆𝒚 𝑻𝒂𝒌𝒆𝒂𝒘𝒂𝒚 Going deep into concepts builds clarity. When the foundation is strong, applying it becomes much easier and more effective. 𝐃𝐚𝐲 20 𝐜𝐨𝐦𝐩𝐥𝐞𝐭𝐞 ✅ Understanding is getting stronger with every step. 💻✨ #Python #30DayChallenge #Day20 #PythonStrings #StringMethods #LearningJourney #LearnToCode #Programming #TechGrowth #Consistency
To view or add a comment, sign in
-
-
📌 Day 49 of #100DaysOfLeetCode 🔹 Problem: Contains Duplicate II (LeetCode 219) 💡 Problem Statement: Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that: nums[i] == nums[j] |i - j| ≤ k In simple words, check if the same number appears again within k distance in the array. ⚙ Approach: Use a HashMap (dictionary) to store the last index of each number. Traverse the array once. If the number already exists in the map: Check the distance between indices. If distance ≤ k, return True. Update the index of the number in the map. ⏱ Complexity: Time Complexity: O(n) Space Complexity: O(n) 🎯 Key Learning: Hashing helps track previously seen elements efficiently and allows solving duplicate problems in linear time instead of nested loops. #LeetCode #DSA #Python #HashMap #CodingChallenge #100DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
Restore IP Addresses – Backtracking Insight Given a string of digits, the goal is to generate all possible valid IP addresses by inserting three dots. Each IP must contain four segments (0–255) and segments cannot have leading zeros unless the value is 0. The solution explores possible 1–3 digit segments, validates them, and uses backtracking to build only valid combinations while pruning invalid paths early. A neat example of constraint-based search and string segmentation. #geekstreak60 #npci #python #backtracking #algorithms #codingpractice #datastructures #problemSolving
To view or add a comment, sign in
-
-
🚀 #100DaysOfCode – Day 52 📌 Problem: Sort Colors (LeetCode 75) 💡 Problem Idea: You are given an array containing only 0s, 1s, and 2s, representing three colors. The task is to sort the array in-place so that all 0s come first, then 1s, and then 2s. ⚡ Key Insight: Instead of using a sorting algorithm, we can solve this in one pass using three pointers. We maintain three regions: Left pointer → position for next 0 Right pointer → position for next 2 Current pointer (i) → traverses the array 🎯 Approach (Dutch National Flag Algorithm): If element is 0 → swap with left, move both left and i If element is 1 → just move i If element is 2 → swap with right, decrease right 📈 Complexity: Time Complexity: O(n) Space Complexity: O(1) (in-place sorting) ✅ Efficient because the array is processed only once. 💭 Learning: This problem is a great example of how pointer techniques can optimize sorting problems without using built-in sort functions. #DSA #LeetCode #Python #CodingJourney #ProblemSolving #Algorithms #100DaysOfCode #LinkedInLearning
To view or add a comment, sign in
-
-
✅ Day 79 of 100 Days LeetCode Challenge Problem: 🔹 #451 – Sort Characters By Frequency 🔗 https://lnkd.in/gMAzHVvS Learning Journey: 🔹 Today’s problem required sorting characters in a string based on their frequency in decreasing order. 🔹 I first built a frequency map (hash map) to count occurrences of each character. 🔹 Then I grouped characters by their frequency and stored them accordingly. 🔹 Finally, I sorted the frequencies in descending order and constructed the result string by repeating characters based on their counts. Concepts Used: 🔹 Hash Map (Frequency Counting) 🔹 Sorting (Descending Order) 🔹 String Construction Key Insight: 🔹 Instead of sorting characters directly, grouping them by frequency makes it easier to reconstruct the result efficiently. 🔹 Sorting only the frequency keys reduces unnecessary operations. Complexity: 🔹 Time: O(n log k) (k = unique characters) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
✅ Day 90 of 100 Days LeetCode Challenge Problem: 🔹 #476 – Number Complement 🔗 https://lnkd.in/gzE6gM7d Learning Journey: 🔹 Today’s problem focused on finding the complement of a number by flipping its binary bits. 🔹 I first converted the integer to its binary representation using bin(num)[2:]. 🔹 Then, I created a helper function to flip each bit: • '0' → '1' • '1' → '0' 🔹 After generating the flipped binary string, I converted it back to an integer using int(..., 2). 🔹 Returned the final complemented value. Concepts Used: 🔹 Binary Representation 🔹 Bit Manipulation 🔹 String Traversal 🔹 Base Conversion Key Insight: 🔹 The complement operation is essentially a bitwise NOT, but only within the significant bits of the number (ignoring leading zeros). 🔹 Converting to binary simplifies the flipping logic for beginners. Complexity: 🔹 Time: O(log n) 🔹 Space: O(log n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
A single train-test split can make a weak model look strong. Cross-validation solves this by evaluating performance across multiple time windows. You train up to a cutoff, forecast forward, shift the cutoff, and repeat. But doing this for multiple models means writing separate loops, managing cutoffs, and combining outputs manually. TimeCopilot removes that overhead. With one method call, you get predictions from every model across every fold. Statistical models, foundation models, naive baselines. All evaluated together without separate pipelines. 🚀 Learn how to use cross-validation to compare foundation models in this example: https://lnkd.in/gx6QmA4S #TimeSeries #Forecasting #Python #CrossValidation
To view or add a comment, sign in
-
-
Day 29 of my #100DaysOfCode challenge 🚀 Today I worked on a Python program to find the maximum occurring character in a string. The goal was to count the frequency of each character and determine which one appears the most. What the program does: • Takes a string as input • Counts the frequency of each character using a dictionary • Tracks the character with the highest occurrence • Handles edge cases like an empty string • Returns the most frequent character How the logic works: 1)A dictionary char_counts is used to store character frequencies 2)The program iterates through each character in the string 3)For every character, its count is updated using .get(char, 0) + 1 4)After counting, another loop checks which character has the highest frequency 5)The character with the maximum count is stored and returned 6)If the string is empty, the function returns None Example: Input: "hello world" Output: Maximum occurring character → l Input: "program" Output: Maximum occurring character → r Why this approach works well: – Uses dictionary for fast lookups – Time Complexity: O(n) – Efficient way to track frequencies Key learnings from Day 29: – Using dictionaries for frequency counting – Iterating through strings efficiently – Handling edge cases in programs – Strengthening string manipulation logic #100DaysOfCode #Day29 #Python #PythonProgramming #StringManipulation #Algorithms #ProblemSolving #CodingPractice #DataStructures #InterviewPrep #LearnByDoing #ComputerScience #BTech #CSE #AIandML #VITBhopal #TechJourney
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development