In 𝗙𝗮𝘀𝘁𝗔𝗣𝗜, 𝗿𝗲𝘁𝘂𝗿𝗻 𝘁𝘆𝗽𝗲 and 𝗿𝗲𝘀𝗽𝗼𝗻𝘀𝗲_𝗺𝗼𝗱𝗲𝗹 describe the success body: a single Pydantic model, or a list of that model—whatever the handler returns on a normal 2xx. When a lookup fails or a rule is broken, you raise 𝗛𝗧𝗧𝗣𝗘𝘅𝗰𝗲𝗽𝘁𝗶𝗼𝗻 so the client gets a proper 𝟰𝘅𝘅 𝘀𝘁𝗮𝘁𝘂𝘀 and a 𝗱𝗲𝘁𝗮𝗶𝗹 𝗽𝗮𝘆𝗹𝗼𝗮𝗱. That is separate from the return type, because raise is not return. 𝗿𝗲𝘀𝗽𝗼𝗻𝘀𝗲_𝗺𝗼𝗱𝗲𝗹 defines how the 𝘀𝘂𝗰𝗰𝗲𝘀𝘀 𝗿𝗲𝘀𝗽𝗼𝗻𝘀𝗲 is built and documented; HTTPException is how you answer with an error without faking a 200. 👉 Detailed breakdown here: https://lnkd.in/gcySJqZX 👉 Code Here: https://lnkd.in/gyf4663s #FastAPI #Python #API #BackendDevelopment #SoftwareEngineering #Pydantic #OpenAPI
More Relevant Posts
-
📌 Problem: Reverse Vowels of a String 💡 Approach: Used the two-pointer technique to reverse only the vowels in the string. Initialize one pointer at the beginning and one at the end. Move both pointers inward until vowels are found, then swap them. Continue this process until both pointers meet. ⚙️ Key Insight: Use a set for fast vowel lookup (O(1)) Two-pointer approach avoids extra space for storing vowels separately ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) (due to string → list conversion) 📚 What I learned: Efficient string manipulation using two pointers Optimizing lookups with hash sets #LeetCode #DSA #Algorithms #Coding #ProblemSolving #Python #TwoPointers #InterviewPreparation #CodingJourney
To view or add a comment, sign in
-
🚀 Solved: Find a String (Substring Count) Challenge Just solved another problem on HackerRank under the Python Strings section! ✅ 🧠 Problem Overview: Count how many times a substring appears in a string — including overlapping occurrences. 🔍 Key Learnings: Practiced string traversal techniques Understood why built-in methods like count() may not always work (no overlapping support) Strengthened concepts of slicing and iteration in Python 💡 Example Insight: For string "ABCDCDC" and substring "CDC", the answer is 2 (overlapping counts matter!). ⚡ Approach Used: Iterated through the string Compared substrings using slicing Counted valid matches efficiently 📈 Problems like this help build strong fundamentals in string manipulation, which is crucial for coding interviews and real-world applications. #Python #HackerRank #Coding #Strings #ProblemSolving #DSA #LearningJourney #AI link of #Solution :- https://lnkd.in/gtqcy8fX
To view or add a comment, sign in
-
-
🚀 Day 62 of #100DaysOfCode Solved “Remove Nth Node From End of List” 🔗 💡 Today’s focus: Two Pointer Technique (Fast & Slow pointers) Instead of calculating length, I used an efficient one-pass approach to remove the target node. 🧠 Key Learnings: Dummy node helps handle edge cases (like removing head) Fast pointer moves n steps ahead Then move both pointers until fast reaches the end Slow pointer lands just before the node to delete ⚡ Clean, efficient & optimal solution (O(n) time, O(1) space) Consistency is starting to feel powerful now 💪 #DSA #LeetCode #CodingJourney #LinkedInLearning #100DaysOfCode #Day62 #Python #ProblemSolving
To view or add a comment, sign in
-
-
Subsets: Classic Backtracking Template Generate all 2^n subsets via binary decision tree — include or exclude each element. Base case: index exceeds array length, save current subset copy. Backtracking: add element, recurse, remove element (backtrack), recurse again. Critical Detail: subset.copy() is essential — without it, all results reference same list, causing incorrect final output. Each subset snapshot must be independent. Time: O(2^n) | Space: O(n) recursion #Backtracking #Subsets #DecisionTree #DeepCopy #Recursion #Python #AlgorithmDesign #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 43/100 – #100DaysOfCode 🚀 Solved LeetCode #2610 – Convert an Array Into a 2D Array With Conditions (Python). Today I practiced hashmap (frequency counting) to construct a 2D array based on given conditions. Approach: 1) Create a frequency map to count occurrences of each element. 2) Initialize an empty result list. 3) While the frequency map is not empty: 4) Create a new row. 5) Iterate through keys and add each number once to the row. 6) Decrease its frequency and remove it if it becomes zero. 7) Add the row to the result. 8) Return the final 2D array. Time Complexity: O(n) Space Complexity: O(n) Learning how frequency maps help in structuring data efficiently 💪 #LeetCode #Python #DSA #HashMap #Arrays #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
LeetCode POTD 💫: Description: A string originalText is encoded using a slanted transposition cipher to a string encodedText with the help of a matrix having a fixed number of rows rows. originalText is placed first in a top-left to bottom-right manner. encodedText is then formed by appending all characters of the matrix in a row-wise fashion. Given the encoded string encodedText and number of rows rows, return the original string originalText. Note: originalText does not have any trailing spaces ' '. The test cases are generated such that there is only one possible originalText. Here's my solution: https://lnkd.in/g2EMmfzE #Python #DSA #Leetcode #DailyChallenge
To view or add a comment, sign in
-
-
Today I worked on an interesting string problem — counting how many times a substring appears in a string without using built-in methods like count(). At first, it seemed straightforward… until I realized an important twist 👇 👉 Built-in count() does not handle overlapping substrings So I implemented a manual sliding window approach: 🔹 Traverse the string from left to right 🔹 Extract substrings using slicing 🔹 Compare each slice with the target substring 🔹 Increment count when a match is found 💡 Example: String → ABCDCDC Substring → CDC There are 2 occurrences, not 1 — because overlapping is allowed. This small problem helped me understand: How string slicing works internally Why built-in functions aren’t always sufficient The importance of handling edge cases like overlapping 🧠 Key takeaway: Sometimes writing logic manually gives deeper insight than relying on shortcuts. Learning step by step and enjoying the process 🔥 #Python #CodingJourney #100DaysOfCode #ProblemSolving #DataStructures #Learning
To view or add a comment, sign in
-
Day 48/100 – #100DaysOfCode 🚀 Solved LeetCode #13 – Roman to Integer (Python). Today I practiced string processing and mapping logic to convert Roman numerals into integers. Approach: 1) Create a dictionary to map Roman symbols to their integer values. 2) Traverse the string from left to right. 3) If the current value is less than the next value, subtract it. 4) Otherwise, add it to the total. 5) Return the final result. Time Complexity: O(n) Space Complexity: O(1) Understanding pattern-based problems in strings 💪 #LeetCode #Python #DSA #Strings #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Reorder Linked List: Split, Reverse, Merge Pattern Reordering a linked list looks tricky at first, but it becomes clean once you break it into three deterministic steps: Find the middle Reverse the second half Merge both halves alternately The key insight is: instead of trying to rearrange nodes in one pass, decompose the problem into simpler sub-problems you already know how to solve efficiently. Complexity: Time: O(n) | Space: O(1) Takeaway: Many linked list problems follow a hidden pattern: 👉 Split → Transform → Merge Once you recognize this, problems like palindrome check, reorder list, and even some cycle-based problems become much easier. #LinkedList #TwoPointers #InPlaceAlgorithms #CodingInterview #ProblemSolving #Python #SoftwareEngineering
To view or add a comment, sign in
-
-
Unpopular opinion: I don't aim for 100% test coverage. Instead, I write tests where it matters most — after something breaks in production. Every incident becomes a test case. Every edge case that slipped through becomes a regression test. After 10 years, this approach has given me: - A test suite that catches real bugs, not theoretical ones - 40% less time writing tests nobody triggers - Confidence where it actually counts Perfect coverage is a vanity metric. Meaningful coverage is a survival strategy. How do you decide what to test? #SoftwareTesting #BackendEngineering #Python #ProductionEngineering
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