😎 One of the Most Clever DSA Questions — 𝐏𝐚𝐫𝐭 𝟑# ▶️ 𝐕𝐚𝐥𝐢𝐝 𝐏𝐚𝐫𝐞𝐧𝐭𝐡𝐞𝐬𝐞𝐬 An easy problem, but it really tests your logical thinking and understanding of Stack data structure. 💡 𝐈𝐍𝐓𝐔𝐈𝐓𝐈𝐎𝐍 ------------ Take a 𝐡𝐚𝐬𝐡𝐦𝐚𝐩 of closing → opening brackets. Iterate over the string s. If you encounter an opening bracket, push it into the stack. If you encounter a closing bracket, check the top of the stack. Pop the previous opening bracket and compare it with the expected one from the hashmap. If they don’t match, the string is invalid. At the end, if the stack is empty, the parentheses are valid. ⚡ Time Complexity: O(n) ⚡ Space Complexity: O(n) Follow Muralikrishna Devarakonda for more 💛... #DSA #LeetCode #CodingInterview #Algorithms #Python #SoftwareEngineering
Valid Parentheses Problem Solution in Python
More Relevant Posts
-
🚀 Simplifying Trees in DSA! 🌳💻 While Arrays and Linked Lists are great linear structures, hierarchical data requires a Non-Linear approach—like Trees! To make revising easier, I created this visual cheat sheet. Just like a real-world tree has a Root and Leaves, a Tree data structure starts at the Root Node and branches out to Intermediate and Leaf Nodes. Here is what I have visually summarized in these notes: ✅ The core difference between Linear and Non-Linear structures ✅ 7 Types of Trees (including BST, Strict, Complete, and Skew Trees) ✅ Array Representation vs. Logical View ✅ Tree Traversal logic (Pre-order, In-order, Post-order) complete with Python code! 🐍 Visualizing the flow from the root down to the leaf nodes is a game-changer for understanding algorithms. Take a look and let me know in the comments—what is your favorite data structure to work with? 👇 #DSA #DataStructures #Algorithms #Python #CodingJourney #TechNotes #SoftwareEngineering #LearnInPublic
To view or add a comment, sign in
-
The Backfill That Changed History 🐍 The analysis looked clean. The trends made sense. The story was clear. A week later — the numbers changed. Not because the logic was wrong. Because the data wasn't final. Backfills, late-arriving records, corrected entries — they quietly rewrite history. In real-world data systems — "final" is often just temporary. 👇 See the visual below — how it breaks your analysis and 4 checks to protect against it. #DataAnalytics #Python #AnalyticsThinking #LearningInPublic
To view or add a comment, sign in
-
-
𝗧𝗵𝗲 𝗴𝗿𝗮𝗽𝗵 𝗹𝗼𝗼𝗸𝗲𝗱 𝘀𝗶𝗺𝗽𝗹𝗲. 𝗧𝗵𝗲 𝗰𝗼𝗱𝗲 𝘁𝗵𝗮𝘁 𝗯𝘂𝗶𝗹𝘁 𝗶𝘁 𝗱𝗶𝗱𝗻'𝘁. Day 22 of #1000DaysOfLearning 🗓️ Today I plotted my first graph in matplotlib — a 𝘀𝗰𝗮𝘁𝘁𝗲𝗿 𝗽𝗹𝗼𝘁. 📊 What I worked through: → plt.scatter() vs plt.plot() — and what each communicates → Controlling 𝗺𝗮𝗿𝗸𝗲𝗿 𝘀𝗶𝘇𝗲, 𝗰𝗼𝗹𝗼𝗿, 𝗹𝗮𝗯𝗲𝗹𝘀, 𝘁𝗶𝘁𝗹𝗲𝘀, 𝗮𝗻𝗱 𝗹𝗲𝗴𝗲𝗻𝗱𝘀 → Grouping data points using slicing and color lists The code gets long for what looks like a simple output. But 𝘁𝗵𝗮𝘁 𝗹𝗲𝗻𝗴𝘁𝗵 𝗶𝘀 𝘁𝗵𝗲 𝗰𝗼𝗻𝘁𝗿𝗼𝗹 — every label, every color, every legend entry is a deliberate line. Matplotlib assumes nothing. 🎯 Also noticed that 𝘇𝗶𝗽 𝗮𝗻𝗱 𝘁𝘂𝗽𝗹𝗲 𝘂𝗻𝗽𝗮𝗰𝗸𝗶𝗻𝗴, which felt less useful in regular Python, come up naturally when working with coordinate data. Made more sense here than any time I saw them before. 💡 #Python #DataScience #Matplotlib #DataVisualization #LearningInPublic
To view or add a comment, sign in
-
-
🔹 Task 3 – Data Cleaning (Python & Pandas) Real-world datasets are often messy and inconsistent. In this step, I worked on cleaning a dataset by: • Handling missing values • Removing duplicate records • Fixing inconsistent data formats • Exploring dataset structure using df.head(), df.shape, and df.dtypes This step ensured that the dataset became structured, reliable, and ready for analysis. Oasis Infobyte https://lnkd.in/dcBc2AGA
To view or add a comment, sign in
-
𝗢𝗢𝗣𝗦 𝘄𝗮𝘀 𝗼𝗻𝗲 𝗼𝗳 𝘁𝗵𝗼𝘀𝗲 𝘁𝗼𝗽𝗶𝗰𝘀 𝗜 𝗸𝗲𝗽𝘁 𝗿𝗲𝘃𝗶𝘀𝗶𝘁𝗶𝗻𝗴 — 𝗻𝗼𝘁 𝗯𝗲𝗰𝗮𝘂𝘀𝗲 𝗜 𝗳𝗼𝗿𝗴𝗼𝘁 𝗶𝘁, 𝗯𝘂𝘁 𝗯𝗲𝗰𝗮𝘂𝘀𝗲 𝗜 𝗻𝗲𝘃𝗲𝗿 𝗳𝘂𝗹𝗹𝘆 𝘁𝗿𝘂𝘀𝘁𝗲𝗱 𝗺𝘆 𝘂𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱𝗶𝗻𝗴 𝗼𝗳 𝗶𝘁. Read about it from multiple sources. Understood the syntax, could follow the examples. But the mental model was always shaky. College lectures sorted that — not by covering something new, but by connecting things in the right order. Inheritance types, method resolution, how one class builds on another — it started making structural sense rather than just syntactic sense. Revisited it all. Coded through single, multi-level, hierarchical, and hybrid inheritance. And for the first time it felt like I actually owned the concept, not just recognized it. #Python #OOP #CS #DataScience
To view or add a comment, sign in
-
-
🚀 DSA Practice Update! Solved Remove Duplicates from Sorted Array on LeetCode with an optimized approach. Brute Force: O(n log n) time | O(n) space Optimized (Two Pointer):O(n) time | O(1) space Choosing the right approach matters more than just solving the problem. The Brute Force approach removes duplicates by using extra data structures like a set and then sorting the array again. Because of sorting, its time complexity becomes O(n log n) and it also requires O(n) extra space. Additionally, it is not in-place, which makes it less efficient and not ideal for optimized solutions. “I used a two-pointer approach where one pointer tracks the position of unique elements and the other scans the array. This gives O(n) time and O(1) space complexity.” Consistency + Optimization = Growth 📈 #DSA #LeetCode #InterviewPrep #Python #CodingJourney
To view or add a comment, sign in
-
-
Solved a nice Binary Tree Problem today: Print all root to leaf paths. The approach is really simple: we'll traverse the tree and store all paths that start at the root and end at a leaf node. So here’s what I did for this problem: • Used recursion with DFS to traverse the tree • Used a path list to keep track of all paths • Whenever I encountered a leaf node, I pushed it into the answer list • Once I visited a node, I removed it from my path list to backtrack and explore all paths An interesting thing I observed while solving this question: Since lists in Python are mutable references, if we push the path into the answer list, it will change all paths in the answer list. Hence, we push a copy of the path into the answer list. This is another nice example of how we use DFS and backtracking for trees. These kinds of small questions really help us solidify our recursion intuitions. #DSA #BinaryTree #Recursion #CodingPractice
To view or add a comment, sign in
-
-
Some instructions are used more than once. When working with data, certain operations tend to repeat. Cleaning a value. Checking a condition. Transforming a piece of information. Applying the same rule across different parts of a dataset. Writing the same set of instructions every time would quickly make code longer and harder to follow. This is where functions come in. A function is simply a way of grouping a set of instructions under a name so that the same logic can be used again whenever it is needed. Instead of rewriting the steps, the program calls the function and runs those instructions again. For example: def check_pass(score): if score >= 50: return "Pass" return "Fail" Once defined, the same logic can be applied wherever it is needed. check_pass(72) check_pass(43) The instructions stay the same. Only the input changes. Functions don’t introduce new logic. They organize existing logic so it can be reused clearly and consistently. And in larger programs, that organization becomes just as important as the logic itself. Day 28 / 30. #30DaysOfDataScience #Python #Functions #ProgrammingLogic #LearningInPublic
To view or add a comment, sign in
-
-
#Day6 of Data Science with Harry Completed the second project: #CodersOfBangalore. In this project, I worked on processing raw Instagram-style data using pure Python and built a small data pipeline to convert unstructured text into structured data for analysis. Work completed: - Data collected - Data parsed - Raw data converted into JSON format - Structured data stored for further analysis This project focused on handling real-world messy data and transforming it into usable structured data without using external libraries like pandas or NumPy. GitHub Repository: https://lnkd.in/g8byfi4A #DataScience #Python #DataEngineering #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
Spent today exploring pandas while starting work with the MovieLens dataset for a recommendation systems project. A few small observations from the process: • pandas makes it incredibly easy to move from raw CSV files to structured data exploration • building a user–movie matrix is just a pivot operation away • debugging environments in VS Code can be surprisingly tricky when working with virtual environments The most interesting part for me was realizing how quickly you can move from: raw rating logs → structured dataset → matrices suitable for recommendation algorithms. Next step: experimenting with similarity-based recommendations using the dataset. Small progress today, but the foundation for something much bigger. Challenge : what pandas method gave the output in the terminal 🙃 🙃 #MachineLearning #DataScience #Python #RecommenderSystems
To view or add a comment, sign in
-
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