Today Coding :- Check whether given two strings are anagrams or not ? Anagrams Means :- same frequency of characters exist in both strings * if lengths are different in two strings those are not anagrams * in String one what all characters are there same should appear in String two as well public class AnagramProgram{ public static void main(String args[]){ String s1="listen"; String s2="silent"; boolean result=isAnagram(s1,s2); if(result){ System.out.println("the given two strings are anagrams"); } else{ System.out.println("the given two strings are not anagrams"); } } public static boolean isAnagram(String s1,String s2){ if(s1.length()!=s2.length()){ return false; } int[] arr=new int[26]; for(int i=0;i<s1.length();i++){ arr[s1.charAt(i)-'a']++; arr[s2.charAt(i)-'a']--; } for(int c:arr){ if(c!=0){ return false; } } } Time Complexity :O(n) Space Complexity: O(1) #interviewPrep #JavaBackendDeveloper #CodingPractice
Java Anagram Checker: Determine if Two Strings are Anagrams
More Relevant Posts
-
🚀 Efficiency Wins: Why Two Pointers Beat Nested Loops 👈👉 Today’s deep dive into the Two Pointer Technique was a perfect reminder that "thinking before coding" is a developer's best skill. Here is how I optimized my approach to solving Two Sum II: 🛠️ Key Technical Takeaways Kill Redundant Flags: I initially used a while(!flag) setup. I quickly realized this was extra baggage—using while (left < right) is the cleaner, more idiomatic "guardrail" that naturally prevents infinite loops. The 1-Indexed Challenge: The problem requires a 1-indexed return. I learned to handle the logic in 0-index but adjust the final output by adding 1 to avoid off-by-one errors. The "Not Found" Safety Net: If no pair exists, returning [-1, -1] is the standard way to signal "not found." Without the left < right condition, the code could crash or loop forever if the target isn't present. ⚡ The Efficiency Edge O(n) vs O(n²): Instead of checking every possible pair (slow), we use two "bookmarks" and find the answer in a single pass. Space Efficiency: By using only two variables, the space complexity stays O(1), no matter how massive the dataset. 🏆 The Milestone Successfully solved Two Sum II using a clean, linear approach! Moving from brute-force to optimized logic feels like a massive level-up. 💻 Code Snippet: function two_pointers(input, target){ let left = 0 let right = input.length - 1 while(left < right){ const currentSum = input[left] + input[right] if(currentSum === target){ return [left + 1, right + 1] } else if(currentSum > target){ right -= 1 } else{ left += 1 } } return [-1, -1] } let input = [2, 7, 11, 15] let target = 9 console.log(two_pointers(input, target)) #DataStructures #Algorithms #LeetCode #CodingInterviews #CleanCode #JavaScript #SoftwareEngineering #ProblemSolving
To view or add a comment, sign in
-
-
𝐀𝐈 𝐜𝐨𝐝𝐢𝐧𝐠 𝐭𝐨𝐨𝐥𝐬 𝐚𝐫𝐞 𝐠𝐫𝐞𝐚𝐭 𝐚𝐭 𝐰𝐫𝐢𝐭𝐢𝐧𝐠 𝐜𝐨𝐝𝐞. 𝐓𝐡𝐞𝐲'𝐫𝐞 𝐭𝐞𝐫𝐫𝐢𝐛𝐥𝐞 𝐚𝐭 𝐤𝐧𝐨𝐰𝐢𝐧𝐠 𝐲𝐨𝐮𝐫 𝐚𝐫𝐜𝐡𝐢𝐭𝐞𝐜𝐭𝐮𝐫𝐞. Copilot and Claude don't know you route everything through a service layer. They don't know which imports are banned. They don't know your layer boundaries. So they generate perfectly valid code that quietly breaks your rules. 𝐈 𝐛𝐮𝐢𝐥𝐭 𝐀𝐫𝐤𝐥𝐢𝐧𝐭 𝐭𝐨 𝐟𝐢𝐱 𝐭𝐡𝐢𝐬. You define your architectural rules in a plain YAML file. Arklint enforces them in pre-commit hooks and CI and exposes them to AI tools via MCP so they check your rules before writing code. 𝐓𝐨𝐝𝐚𝐲 it hit 𝐯1.0.0. Native packages for Python, Node.js, and .NET. But 𝐥𝐚𝐧𝐠𝐮𝐚𝐠𝐞 𝐚𝐠𝐧𝐨𝐬𝐭𝐢𝐜 beyond that. If Python's on your machine, Arklint works on any codebase. 📦 𝐏𝐲𝐏𝐈 → 𝐩𝐢𝐩 𝐢𝐧𝐬𝐭𝐚𝐥𝐥 𝐚𝐫𝐤𝐥𝐢𝐧𝐭 📦 𝐧𝐩𝐦 → 𝐧𝐩𝐱 𝐚𝐫𝐤𝐥𝐢𝐧𝐭 📦 𝐍𝐮𝐆𝐞𝐭 → 𝐝𝐨𝐭𝐧𝐞𝐭 𝐭𝐨𝐨𝐥 𝐢𝐧𝐬𝐭𝐚𝐥𝐥 𝐚𝐫𝐤𝐥𝐢𝐧𝐭 🌐 𝐀𝐧𝐲 𝐨𝐭𝐡𝐞𝐫 𝐬𝐭𝐚𝐜𝐤 → 𝐣𝐮𝐬𝐭 𝐧𝐞𝐞𝐝𝐬 𝐏𝐲𝐭𝐡𝐨𝐧. "𝒑𝒊𝒑 𝒊𝒏𝒔𝒕𝒂𝒍𝒍 𝒂𝒓𝒌𝒍𝒊𝒏𝒕" 𝐚𝐧𝐝 𝐲𝐨𝐮'𝐫𝐞 𝐝𝐨𝐧𝐞. If this solves a problem you've had 𝐭𝐫𝐲 𝐢𝐭, 𝐬𝐭𝐚𝐫 𝐢𝐭 𝐨𝐧 𝐆𝐢𝐭𝐇𝐮𝐛, and if you want to shape where it goes next, Want native support for your stack? The repo is open and contributions very welcome! Built this with Claude as my co-pilot, the irony of using AI to build a tool that keeps AI in check isn't lost on me. 😄 𝐋𝐢𝐧𝐤 𝐢𝐧 𝐜𝐨𝐦𝐦𝐞𝐧𝐭𝐬 👇 #SoftwareArchitecture #Devtools #AIEngineering #CleanArchitecture #CleanCode #TechDebt #SoftwareEngineering #PyPI #npm #NuGet
To view or add a comment, sign in
-
-
Coding Ninja's Problem of The Day Isomorphic Strings You have been given two strings, 'str1' and 'str2'. Your task is to return true if the given two strings are isomorphic to each other, else return false. Note :Two strings are isomorphic if a one-to-one mapping is possible for every character of the first string ‘str1’ to every character of the second string ‘str2’ while preserving the order of the characters. All occurrences of every character in the first string ‘str1’ should map to the same character in the second string, ‘str2’. For example :If str1 = “aab” and str2 = “xxy” then the output will be 1. ‘a’ maps to ‘x’ and ‘b’ maps to ‘y’. If str1 = “aab” and str2 = “xyz” then the output will be 0. There are two different characters in 'str1', while there are three different characters in 'str2'. So there won't be one to one mapping between 'str1' and 'str2'. Detailed explanation ( Input/output format, Notes, Images ) Sample Input 1 :aab xxy Sample Output 1 :1 Explanation of sample input 1:The character ‘a’ maps to ‘x’ and ‘b’ maps to ‘y’. Hence, the answer is 1 in this case. Sample Input 2 :aab xyz Sample Output 2 :0 Constraints :1 <= |str1|, |str2| <= 10^3 |str1| is the length of the string str1, and |str2| is the length of the string str2. Follow Up:Can you solve this in O(N) time?
To view or add a comment, sign in
-
-
Sonnet 3.x and code refactoring: you'd spend more energy convincing the model that a trait extraction exists than actually doing the extraction yourself. Opus 4.6 : you mention there's a refactoring by composition possible, and it figures out on its own that traits are the right tool. Straight to "pure mechanical extraction of already-working code." No hand-holding. Fair point though: part of that jump might not be the model alone. Claude Code's harness has gotten seriously better at feeding context the right way. Hard to tell where the model ends and the tooling begins. Either way, the result is the same: you're still driving, but the car finally has power steering. #FirstYouHadToExplainWhatATraitWas #ThenExplainWhyItMatteredHere #ThenBegItToActuallyDoIt #NowYouSayCompositionAndItConnectsTheDots #CouldBeTheCarCouldBeTheRoad #EitherWayWereMoving #Laravel #PHP #TraitExtraction #CodeRefactoring #SoftwareEngineering #AIAssistedDevelopment #ClaudeCode #Opus46 #LLM #AI
To view or add a comment, sign in
-
-
C# keeps adding syntax to reduce boilerplate, yet every new shortcut quietly shifts how developers reason about state. Field-backed properties in C# 14 look like a small convenience, but they subtly change the boundary between explicit state and compiler-managed behavior. In many codebases, properties were historically a deliberate abstraction: a clear separation between public access and internal state management. With field-backed properties, that boundary becomes implicit. The compiler now decides how storage is generated, while the developer writes only the surface API. This sounds efficient, but it also hides an architectural decision inside the language itself. In everyday application code this may feel harmless. But in larger systems—especially those influenced by #SoftwareArchitecture principles or strict domain models in #CSharp—implicit storage can blur the intent behind a property. Is the property merely a convenience wrapper, or is it a meaningful abstraction that protects invariants? The expectation behind many modern language features is productivity. The reality is often a gradual shift from explicit design toward implicit behavior. In the #DotNet ecosystem this tension appears frequently: convenience reduces code, yet it can also reduce the visibility of architectural decisions. Field-backed properties illustrate a recurring pattern in language evolution. Less syntax does not automatically mean clearer design; sometimes it simply moves complexity to a place where developers stop noticing it. Link for first comment:
To view or add a comment, sign in
-
Claude Code — How to use it effectively 🎯 What “Claude code” means Using Claude to: 👉 Write code 👉 Debug errors 👉 Explain logic 👉 Build apps faster ⚙️ Core capabilities (practical) 🧠 Generate code (Python, JS, HTML, etc.) 🛠️ Fix bugs (paste error → get solution) 📖 Explain code (line-by-line clarity) 🔄 Refactor & optimize 🧪 Write test cases 🧑💻 How to use Claude for coding (step-by-step) 1. Clear prompt (most important) 👉 Bad: “Write code” ❌ 👉 Good: “Write a Python script to extract YouTube transcript and summarize it using API” 2. Use iterative refinement Step 1: Get basic code Step 2: Ask to improve Step 3: Add features 👉 Build in layers 3. Debug smartly Paste error message Ask: 👉 “Explain error + fix + improved version” 4. Ask for explanation 👉 “Explain like beginner” 👉 “Give flow diagram logic” 🔧 Example use case (your interest) Build “TubeLearn app” Prompt: 👉 “Create a simple web app that takes YouTube link, extracts transcript, summarizes using AI, shows bullet notes” Claude will: Generate frontend code Suggest APIs Give step-by-step build ⚠️ Common mistakes Vague prompts ❌ Copy-paste without understanding ❌ Not testing code ❌ 💡 Pro tips Ask for modular code Request comments inside code Use real examples + sample data ✔️ Simple formula 👉 Clear prompt + Iteration + Testing = Working code
To view or add a comment, sign in
-
I built a code converter a while back — Python to JS and back, with LLM under the hood. I've since rebuilt the pipeline significantly. Added test coverage checks, refinement loops, and a step where the model decides whether the converted code actually needs another pass. The reason: LLMs hallucinate. A single-pass conversion isn't reliable enough. So the pipeline now runs the actual test suite after each conversion, feeds the results back to the model, and loops until the tests pass and coverage meets the threshold. But loops cost time. And inference isn't instant to begin with. So now the pipeline takes a while. And a long-running pipeline with no feedback is flying blind — you don't know if it's thinking, stuck, or silently wrong. That's why I added a visualizer. Which got me thinking about the "GUI is dead, future is CLI" takes I've been seeing lately. I don't think the container matters — it can be a web UI, a TUI, a progress stream in the terminal. Even Claude Code streams every step rather than returning one big answer at the end. The interface will keep changing. The need to see what's happening won't. Here's what it looks like in action 👇 Demo: https://lnkd.in/gjxkTrEX #AIEngineering #LLM #AgenticAI
To view or add a comment, sign in
-
💡 A small algorithmic discovery while revisiting sorting algorithms While revisiting sorting concepts like Bubble Sort and Insertion Sort, I tried implementing my own approach to sort an array. Interestingly, the logic that came to my mind turned out to be very similar to the idea behind Insertion Sort. The approach was simple: • Start from the second element of the array • Compare the current element with previous elements • Shift larger elements to the right • Insert the current element in its correct position Here is the JavaScript snippet I came up with: const getSortedArr = (arr) => { const n = arr.length; for (let i = 1; i < n; i++) { let curr = arr[i]; let prev = i - 1; while (arr[prev] > curr && prev >= 0) { arr[prev + 1] = arr[prev]; arr[prev] = curr; prev--; } } return arr; }; 📊 Complexity Analysis • Time Complexity - Best Case: O(n) - Average Case: O(n²) - Worst Case: O(n²) • Space Complexity - O(1) (in-place sorting) #JavaScript #Algorithms #Sorting #Learning #SoftwareEngineering #ProblemSolving
To view or add a comment, sign in
-
🔍 Vibe coding needs a safety net We're in the era of vibe coding. AI writes most of the code. You ship fast, iterate faster. But here's the problem: nobody's checking the code. Unclosed brackets. SQL injection risks. Hardcoded secrets. Copy-pasted blocks everywhere. AI doesn't always catch what AI creates. That's why I built CodeLens which is a instant code analysis tool for the vibe coding era. Paste your code. Get results in seconds: 🔍 Syntax errors & unclosed tags 🛡️ Security vulnerabilities 📊 Code quality & complexity scores 🔥 Complexity hotspots ♻️ Duplication detection ⏱️ Technical debt estimation No signup. No install. 6 languages supported. 🛠️ Tech Stack: ⚛️ React + TypeScript ⚡ Vite 🎨 Tailwind CSS + shadcn/ui 🧊 Three.js (React Three Fiber) for 3D visuals 📊 Recharts for data visualization If you're vibe coding, at least vibe code safely. 👉 Try it: https://lnkd.in/g_2sznp8 #VibeCoding #CodeQuality #DeveloperTools #AI #React #TypeScript #Vite #TailwindCSS #ThreeJS #BuildInPublic
To view or add a comment, sign in
-
Why Everyone is Talking About FastAPI: A Visual Breakdown If you are building web applications today, speed and developer experience aren't just "nice-to-haves"—they are requirements. Here is a breakdown of why FastAPI has become the go-to framework for modern Python backends: 1. The Core Advantages (The "Top Row") Super Speed: Built on top of Starlette and Uvicorn, it handles requests asynchronously. This means it can manage many connections at once without breaking a sweat. Automatic Docs: This is a game-changer. The moment you write your code, FastAPI generates Swagger UI and ReDoc pages. No more manually updating documentation! Data Validation with Pydantic: It uses Python type hints to ensure that the data coming in (like an email or a price) is exactly what you expect before your code even touches it. Intuitive Coding: It’s "Pythonic." The syntax is clean, making it easier to read, maintain, and scale. 2. The Request Flow (The "Middle Engine") Think of FastAPI as an organized assembly line: Client: Your app or browser sends a request. Uvicorn: The high-speed server that picks up the request. Starlette: The toolkit that routes the request to the right place. FastAPI Logic: This is where the magic happens—handling security (authentication), talking to your Database, and running Background Tasks. Response: The user gets back clean JSON or HTML instantly.
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