Day 14- What I Learned in a Day(JAVA) Concatenation Operator :("+") • Used to combine two or more strings • Commonly used to join text with variables • Helps in displaying meaningful output messages Increment Operator: • Used to increase a variable value by one • Can be used in pre-increment(++varname) and post-increment(varname ++) form Decrement Operator: • Used to decrease a variable value by one • Can be used in pre-decrement(--varname) and post-decrement(varname--) form. 🔹 I practiced small programs to understand how these operators behave during execution and how output changes based on their usage. Practiced 👇 #Java #JavaProgramming #OperatorsInJava #CodingPractice #LearningJourney #ProgrammingLife #TechSkills #FutureDeveloper 🚀
More Relevant Posts
-
Day 16-What I Learned In a Day(JAVA) 🔹 Assignment Operators Used to assign and update values in variables. Symbols: =, += ,-=, *=, /= ,%= . 🔹 Relational Operators Used to compare two values and return true or false. Symbols: > ,<, >=, <=, == ,!= . 🔹 Conditional (Ternary) Operator Short form of if-else used for simple decision making. Symbol: condition ? value1 : value2; 🔹 Type Casting Used to convert one datatype into another (Widening & Narrowing). Symbol: (datatype) Practiced 👇 #Java #JavaLearning #ProgrammingBasics #CodingJourney #SoftwareDevelopment #LearnToCode
To view or add a comment, sign in
-
Day 26 - What I Learned In a Day(JAVA) he switch statement is used to select one block of code from multiple options based on the value of an expression. Workflow of Switch Statement 1️⃣ Expression is evaluated The value inside switch(expression) is calculated. 2️⃣ Value is compared with cases The result is compared with each case value. 3️⃣ Matching case executes If a matching case is found, that block of code runs. 4️⃣ break stops the switch break exits the switch statement after executing the matched case. 5️⃣ default runs if no match If none of the cases match, the default block executes. Syntax: switch(expression) { case value1: // statements break; case value2: // statements break; case value3: // statements break; default: // statements } #Java #Programming #JavaSwitch #DecisionMaking #Coding #CaseStatement #BreakStatement #DefaultCase
To view or add a comment, sign in
-
-
Day 59 — LeetCode Progress (Java) Problem: Count the Number of Consistent Strings Required: Given a string allowed and an array of strings words, return the number of consistent strings (strings that contain only characters from allowed). Idea: Use a HashSet for fast lookup to check whether each character in a word is allowed. Approach: Store all characters of allowed in a HashSet. Iterate through each word: Check every character in the word If any character is not in the set, the word is invalid Count all valid (consistent) words. Time Complexity: O(n × m) Space Complexity: O(1) #LeetCode #DSA #Java #HashSet #Strings #Algorithms #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 14/100 – LeetCode Challenge 🚀 Problem: #169 Majority Element Difficulty: Easy Language: Java Approach: Sorting + Middle Element Time Complexity: O(n log n) Space Complexity: O(1) 🔍 Key Insight: The majority element appears **more than ⌊n / 2⌋ times** in the array. If we **sort the array**, the majority element must occupy the **middle position** because it appears more than half of the time. Therefore, the element at index **n/2** will always be the majority element. 🧠 Solution Brief: First sorted the array using `Arrays.sort()`. Since the majority element appears more than half of the array length, it will always be positioned at the middle index. Finally returned `nums[nums.length / 2]` as the majority element. 📌 What I Learned: Understanding problem constraints can simplify the solution significantly. Sometimes a simple observation (like majority occupying the middle after sorting) can avoid more complex implementations. #LeetCode #Day14 #100DaysOfCode #Java #DSA #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 73 / 100 Days of LeetCode Question: Check if Binary String Has at Most One Segment of Ones Given a binary string s, determine whether it contains at most one continuous segment of '1's. Solved in Java by checking whether the pattern "01" exists in the string. If "01" appears, it means a new segment of 1s starts after a 0, which violates the condition. This provides a clean and efficient solution. Consistency > perfection. Day 74 loading 🔥 #100DaysOfCode #LeetCode #Java #DSA #ProblemSolving
To view or add a comment, sign in
-
-
Day 45 — LeetCode Progress (Java) Problem: Intersection of Two Arrays Required: Given two integer arrays nums1 and nums2, return an array containing their unique intersection elements. Idea: Use a HashSet to efficiently track elements from the first array and check their presence in the second array. Approach: Create a HashSet to store all elements from nums1. Traverse nums1 and insert each element into the set. Initialize a list to store the intersection result. Iterate through nums2: If an element exists in the set: Add it to the result list. Remove it from the set to avoid duplicates. Convert the result list into an array and return it. Time Complexity: O(n + m) n = length of nums1 m = length of nums2 Space Complexity: O(n) #LeetCode #DSA #Java #HashSet #Arrays #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 12/100 – LeetCode Challenge Problem: Middle of the Linked List Today’s problem focused on finding the middle node of a singly linked list. Approach: Used the Two-Pointer Technique (Slow & Fast pointers). slow moves one step at a time fast moves two steps at a time When fast reaches the end of the list, slow will be at the middle node Complexity: Time: O(n) Space: O(1) Concepts Practiced: Linked List traversal Two-pointer technique Efficient single-pass solution #100DaysOfCode #LeetCode #DSA #Java #LinkedList #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
#day334 of #1001daysofcode problem statement (1009): Complement of Base 10 Integer 💡 Approach: To find the complement of a number, I converted it into binary and flipped every bit (0 → 1 and 1 → 0). After flipping the bits, the resulting binary string was converted back to decimal. Example: 5 → Binary: 101 Complement: 010 → 2 ⏱ Time Complexity: O(log n) 🧠 Space Complexity: O(log n) #1001DaysOfCode #DSA #Java #LeetCode #ProblemSolving Shivam Mahajan #leetcode
To view or add a comment, sign in
-
-
Solved 3Sum and 4Sum problems on LeetCode. In 3Sum, I used sorting + two pointer approach and handled duplicate elements carefully. After sorting, if the first element becomes greater than 0, I break the loop because sum cannot be 0 after that. That logic became very clear to me. In 4Sum, I extended the same idea — fixed two elements and used two pointers for the remaining part. Also used long for sum to avoid overflow. Runtime and memory were decent, and solution got accepted. Agar koi suggestion ho ya better approach pata ho to please share 🙌 #DSA #Java #LeetCode #ProblemSolving #CodingJourney #LearningInPublic #Consistency
To view or add a comment, sign in
-
𝗬𝗼𝘂 𝗵𝗮𝘃𝗲 𝗯𝗲𝗲𝗻 𝘂𝘀𝗶𝗻𝗴 𝗕𝗶𝗻𝗮𝗿𝘆 𝗦𝗲𝗮𝗿𝗰𝗵 𝘄𝗿𝗼𝗻𝗴. It is not just for sorted arrays. The real definition — "Eliminate HALF the search space with each decision." That one shift in thinking unlocks 20+ LeetCode problems. Swipe to see the template, live code, and 7 problems you can now solve with one pattern. 👇 Save this. 🔖 #DSA #BinarySearch #Java #LeetCode #CodingInterview #DebugWithPurpose
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