🚀 Day 48 of #100DaysOfCode — Getting the Last Element of an Array Hey everyone! 👋 Today’s challenge was simple but fundamental: returning the last element of an array without modifying it. 👨💻 What I practiced today: ✅ Accessing array elements by index ✅ Using negative indexing in Python ✅ Writing clean, one-line return statements ✅ Handling edge cases implicitly 📌 Today's Task: ✔ Create a function get_last(arr) ✔ Return the last element of the given array ✔ Keep the original array unchanged 🧠 Example: Input: [1, 2, 3] Output: 3 Input: ["a", "b", "c"] Output: "c" 💡 Key Takeaway: Even simple operations like accessing the last element are essential building blocks in programming. Python’s negative indexing makes this elegant and readable. #100DaysOfCode #Python #Arrays #Indexing #BeginnerFriendly #CodingJourney #Day48
Pradumya Gupta’s Post
More Relevant Posts
-
🚀 Day 27 of #100DaysOfCode Today’s problem: LeetCode 3010 – Divide an Array Into Subarrays With Minimum Cost I At first glance, it felt like a DP problem. But after breaking it down, the solution turned out to be simple and elegant. 🧠 Key Insight: Split the array into 3 contiguous subarrays Cost of a subarray = its first element First subarray always starts at index 0 To minimize cost → pick the two smallest elements from the remaining array ✅ Python Solution: Copy code Python class Solution: def minimumCost(self, nums: list[int]) -> int: return nums[0] + sum(sorted(nums[1:])[:2]) 💡 Learning: Don’t jump to complex solutions too quickly. Sometimes, the optimal answer comes from understanding the problem constraints deeply. 📈 Staying consistent, one problem at a time. #100DaysOfCode #Day27 #LeetCode #Python #DSA #ProblemSolving #Consistency #LearningInPublic #Learning
To view or add a comment, sign in
-
-
Python Lists: When Single Values Aren’t Enough int, float, and string felt powerful, until I realized real programs work with collections. That’s where lists shine 👇 🔹 Store multiple values in one variable 🔹 Access items with indexing (starts at 0) 🔹 Use len() to count elements 🔹 Check existence with in 🔹 Slice lists just like strings (list[1:3]) 💡 Best part? If you understand strings, you already understand lists. Same rules. Same logic. More power. One concept learned → many doors unlocked #Python #LearningInPublic #ProgrammingBasics #VSCode #DeveloperJourney
To view or add a comment, sign in
-
-
Day 4 of my Python Journey: Making data types play nice! 🐍 Today was all about Type Casting. In Python, data doesn't always arrive in the format we need. I spent today learning how to manually convert data types to keep my code running smoothly. What I covered: Implicit vs. Explicit Conversion: Letting Python do the work vs. taking control myself. The Big Three: Using int(), float(), and str() to bridge the gap between user input and mathematical operations. Common Pitfalls: Why you can't just turn "Hello" into an integer (and how to handle those errors). It’s a simple concept, but it’s the "glue" that holds more complex logic together. Onward to Day 5! #Python #CodingNewbie #100DaysOfCode #DataScience #TechLearning
To view or add a comment, sign in
-
-
Today I worked on a Python logic exercise focused on list traversal, duplicate handling, and comparing two lists of different lengths using pure loops. 🔹 What this code does: Takes two lists with different lengths, both containing repeated numbers Iterates through them safely using index-based nested loops Collects common elements while preserving order Removes duplicate values manually, without using built-in shortcuts like set() 🔹 Why I approached it this way: Instead of relying on Python conveniences, I deliberately used: Explicit for loops Conditional logic Intermediate lists This forced me to think about: Boundary conditions when list sizes don’t match How duplicates are detected step by step Writing logic that doesn’t assume equal input sizes 🔹 Key takeaway: Understanding fundamentals—especially edge cases like unequal input lengths—builds stronger problem-solving skills than jumping straight to optimized one-liners. Consistent practice, steady improvement. 💻📈 #Python #Programming #LogicBuilding #DataStructures #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
90% of DSA starts here: Mastering Arrays in Python 📉 They say if you can't handle Arrays, you can't handle Data Structures. Today, I tackled Day 2 of the Chai aur DSA series, and it wasn't just about simple lists. The session with Hitesh Choudhary went deep into how Python handles arrays differently from languages like C++ or Java. My Key Technical Takeaways: Memory Management: Unlike static arrays in C++, Python arrays are dynamic and can handle heterogeneous data. The Power of NumPy: I learned why numpy is industry-standard for creating 1D, 2D, and even 3D arrays efficiently. Slicing Magic: Python makes operations like reversing an array (arr[::-1]) or slicing sub-arrays incredibly intuitive compared to traditional loops. Building a solid foundation here to ensure smooth sailing when we get to Sliding Windows and Two Pointers later! 🚀 Question: Do you prefer using Python lists or NumPy arrays for your daily tasks? #DataStructures #Python #NumPy #CodingJourney #ChaiAurDSA #SoftwareEngineering
To view or add a comment, sign in
-
-
Problem: Contains Duplicate (LeetCode #217) 💡 Concept Learned: Today I practiced a simple LeetCode problem: Contains Duplicate using Python. At first, I tried the brute-force approach by comparing each element with every other element using nested loops. It works, but it’s slow when the list becomes large. Then I learned a better way using a set. A key insight: If an element is already present in the set while traversing the array, a duplicate exists. 🎯 Key Takeaway: Choosing the right data structure makes a huge difference. A Hash Set helps reduce the time complexity from O(n²) to O(n) by enabling constant-time lookups. 📈 Slowly building confidence by solving one problem at a time and learning from mistakes. #DSA #LeetCode #100DaysOfCode #HashTable #Set #ProblemSolving #Python #CodingJourney #LearningInPublic #CodeNewbie
To view or add a comment, sign in
-
-
Today I learned about Lambda Functions in Python 🐍 A lambda function is a small, anonymous function written in a single line using the lambda keyword. It’s mainly used for: ✅ Short and simple operations ✅ Writing compact code ✅ Using inside functions like map(), filter(), and sorted() Example idea: Instead of writing a full function to square a number, we can do it in one line with a lambda function. Less code. Same logic. Cleaner style. Understanding these small tools really helps in writing more Pythonic and efficient code. Learning one concept every day 🚀 #Python #DataScience #LearningInPublic #Programming #100DaysOfCode #CareerSwitch
To view or add a comment, sign in
-
-
Day 01 Today I focused on the building blocks of Python: 🔹 Data Types – Define the type of data (int, float, string, list, tuple, set, dict) 🔹 Variables – Store and reuse values in your program 🔹 Identifiers – Names given to variables, functions, and objects (must follow rules) 🔹 Type Casting – Convert one data type to another using int(), float(), str() Strong fundamentals create strong programmers 💻 One step at a time — let’s keep learning and growing! #Python #ProgrammingBasics #LearningJourney #BeginnerFriendly #CodingLife #Students
To view or add a comment, sign in
-
-
Day 5 — #30DaysOfPythonWithKapil 🚀 Today I solved a Python problem: Armstrong Number The task was to: Read a number N and check whether it is an Armstrong Number or not. 👉 An Armstrong Number is a number where the sum of each digit raised to the power of total digits equals the number itself. Example: 1634 → --- What I practiced & understood today: ✅ ✔ Converting number to string for digit access ✔ Using len() to get total digits ✔ Applying power operation on each digit ✔ Looping through digits using for loop ✔ Strengthening logical thinking step-by-step Sharing my solution below 👇 (Attached code screenshot) This daily practice is really helping me understand logic + fundamentals more clearly. Small steps every day, but staying consistent 💪 Let’s keep learning and growing 🚀💻 #Python #CodingJourney #ArmstrongNumber #ProblemSolving #Consistency #LearnInPublic #LogicBuilding #FutureDataScientist
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