Interview Prep Hub
🚀 Helping software engineering students crack coding interviews with daily challenges, system design basics, and career tips.
07/01/2026
අද අපි බලමු Relational Database වල Columnstore Index කියන්නෙ මොකක්ද කියලා 💡
Massive datasets එක්ක වැඩ කරනකොට performance කියන්නෙ challenge එකක්. Analystics and reporting queries ගොඩක් වෙලාවට rows million ගනන් scan කරනවා. මේ වගේ scenario වලදි performance වැඩි කරගන්න අපිට මේ Columnstore Index use කරන්න පුලුවන්.
අපි මුලින්ම Row-Oriented Storage එක ගැන බලමු.
🍀 Row-Oriented Storage
Traditional table එකක එක row එකකින් එක record එකක් represent වෙනවා. සමහර වෙලාවට අපිට query කරන්න ඕන වෙන්නෙ columns කීපයක් විතරයි. හැබැයි row-oriented storage එකකදි අපිට අවශ්ය columns ටික extract කරගන්න entire row එකම memory එකට ගන්න වෙනවා. Rows විශාල ප්රමානයක් query කරන analytical queries වගේ query වලදි මේ විදිට inefficient. උදාහරණයක් විදියට හිතන්න rows million ගානක් තියෙන retail transaction table එකක්. මේ table එකේ columns විදියට TransactionID, CustomerID, ProductID, Quantity, UnitPrice, TransactionDate, StoreLocation, PaymentMethod වගේ columns තියෙන්න පුලුවන්. අපිට specific day එකක total sales බලාගන්න ඕන උනාම TransactionDate column එක use කරලා ඒ date එකට අදාල records ටික ගන්න පුලුවන්. හැබැයි Quantity * UnitPrice වල sum එක ගන්න අපිට මුලු row එකම fetch කරන්න වෙනවා.
🍀Column-Oriented Storage (Columnstore Index)
සරලවම columnstore index එකකදි data store වෙන්නෙ column විදියට. සෑම column එකක්ම separately store වෙනවා. ඒ වගේම column එක තුල data compress වෙනවා. Columnstore index එකෙන් අපිට advantages කීපයක් ලබාගන්න පුලුවන්.
1. Reduced I/O: අපි columns කීපයක් පමනක් query කරනකොට, database එක disk එකෙන් read කරන්න ඕන මේ specific column විතරයි. ඒක නිසා I/O operations reduce වෙනවා.
2. Enhanced Compression:Column එකේ තියෙන data සේරම typically same data type. ඒ වගේම similar values තියෙන්න පුලුවන්. ඒක නිසා row-oriented storage එකකට වඩා compression ratio එක වැඩී. Disk space usage එක මේ නිසා අඩු වෙනවා.
3. Vectorized Query Processing: සරලවම අපිට aggression, filtering වගේ operations, column එක තුල batch විදියට simultaneously කරන්න පුලුවන්. Row-by-row යන්න ඕන නෑ. ඒක නිසා CPU එක efficiently utilize කරන්න පුලුවන්.
අපි කලින් ගත්ත retail transaction table example එකම columnstore index එකට apply කලොත්, මෙතනදි අපිට read කරන්න වෙන්නෙ TransactionDate, Quantity සහ UnitPrice column විතරයි. මේ column සේරම separately store වෙලා තියෙනවා. Query engine එකට මේ columns, batch විදියට efficiently process කරලා sum එක ගන්න පුලුවන්.
28/11/2025
🚨 We’re Live Now! 💚
Join us for the first-ever Vue.js Sri Lanka Virtual Meetup 🎉
🎙️ Why Vue.js — The Evolution of Single Page Applications
by Nico Devs, Senior Software Engineer at Tighten
📺 Watch Live on YouTube:
👉 https://shorturl.at/oM6hg
Hop in, learn, and be part of the Sri Lankan Vue.js community’s first chapter! ⚡
13/11/2025
We are super excited to share that we’re hosting our first-ever Virtual Meetup! 🇱🇰💚
It’s going to be an awesome opportunity to connect, learn, and grow together as Vue developers.
Details coming soon — you don’t want to miss this! ⚡
Something exciting is brewing for all Vue lovers in Sri Lanka 🇱🇰💚
We’re getting ready to host our first-ever Vue.js Sri Lanka Virtual Meetup!
Stay tuned — details dropping soon! ⚡
06/11/2025
Java Concept Breakdown Article Series එකෙන් අද අපි බලමු Java වල Runnable සහ Callable Interfaces ගැන.
අපි Java program එකක් develop කරනකොට data fetch කරන්න, computations කරන්න සහ background jobs perform කරන්න වගේ tasks වලට separate threads බහුලව use කරනවා. මෙන්න මේ වැඩේ කරගන්න තමයි අපිට මේ Runnable සහ Callable Interfaces දෙක ඕන වෙන්නෙ.
මේ interfaces දෙක use කරලා අපිට thread එකකින් හෝ executor එකකින් execute වන tasks represent කරන්න පුලුවන්. හැබැයි මේ interfaces දෙකේ results, exceptions සහ ex*****on control handle වෙන විදිය වෙනස්. අපි බලමු ඒ differences මොනවද කියලා.
🧵What is Runnable?
Runnable තමයි මේ interface දෙකෙන් simple ම interface එක. මේකෙන් අපිට result එකක් return කරන්නෙ නැති task එකක් represent කරන්න පුලුවන්. මේක introduce කරේ Java 1.0 වලදි. ඒ වගේම මේකෙ run() method එක තියෙනවා.
public interface Runnable {
void run();
}
Exception handling නැති සහ value එකක් return කරන්නෙ නැති task වලට අපිට runnable interface එක use කරන්න පුලුවන්. (fire-and-forger tasks)
⚙️What is Callable?
Java 5 වල java.util.concurrent package එකේදි callable interface එක introduce කරේ runnable interface එකේ තියෙන limitations address කරන්න. මේකෙන් අපිට result එකක් return කරන සහ checked exceptions throw කරන tasks represent කරන්න පුලුවන්.
public interface Callable {
V call() throws Exception;
}
මේකෙදි V වලින් represent කරන්නෙ task එකෙන් return කරන result එකේ type එක. අපි callable instance එකක් executor service එකකට submit කරාම Future object එකක් return වෙනවා. අපිට මේ future object එක use කරලා results retrieve කරගන්න පුලුවන්. ඒ වගේම task එක complete ද කියලා බලන්නත් පුලුවන්.
🌍Real-World Usage
Logging or monitoring services implement කරනකොට අපිට Runnable interface එක බහුලව use කරන්න පුලුවන්. උදාහරණයක් විදියට periodically logs write කරන background threads වලට අපිට Runnable use කරන්න පුලුවන්.
API වලින් data fetch කරන්න, long-running computations කරන්න වගේ return value එකක් තියෙන tasks වලට callable interface එක use කරන්න පුලුවන්.
23/10/2025
Java Concept Breakdown Article Series එකෙන් අද අපි බලමු Java වල Threads සහ Executors ගැන.
අපි efficient java application එකක් develop කරනකොට concurrency management කියන්නෙ ගොඩක් important aspect එකක්. Java වලදි multitasking handle කරන්න ක්රම කීපයක් තියෙනවා. මේ අතරින් Threads සහ Executors කියන්නෙ commonly use වෙන approach දෙකක්. මේ approach දෙකම use වෙන්නෙ tasks concurrently execute කරන්න. හැබැයි මේ approach දෙක වැඩ කරන විදිය significantly වෙනස්.
🧵What are Threads?
සරලව thread එකක් කියන්නෙ process එකක execute වන smallest unit එක. Java වලදි අපිට Thread class එකෙන් extend කරලා හෝ Runnable or Callable interface implement කරලා thread එකක් හදන්න පුලුවන්. මේ threads independently run වෙනවා. හැබැයි manually threads manage කරන එක ටිකක් complex.
අපි manually threads manage කරනවනම් thread creation සහ ඒ threads වල lifecycle එක handle කරන්න ඕන. ඒ වගේම threads ගොඩක් start කරොත් high memory consumption එකක් වෙන්න පුලුවන්. ඒ වගේම threads අතරෙ coordination සහ safely threads shut down කරන එක tricky.
ඒක නිසා මේ approach එක small programs වලට manageable උනත් large or concurrent systems වලදි හොදින් scale වෙන්නෙ නෑ.
⚙️What Are Executors?
Thread management simplify කරන්න Java 5 වලදි Executor framework එක introduce කරලා තියෙනවා.
මෙතනදි වෙන්නෙ අපි threads manually create සහ manage කරනවා වෙනුවට, task එකක් executor එකට submit කරන්න පුලුවන්. එතකොට executor එකෙන්, thread allocation, ex*****on සහ termination control කරනවා. මේක කරන්න executor එක thread pool එකක් use කරනවා. මේ නිසා අපිට constantly thread create සහ destroy කරන overhead එක අඩු කරගන්න පුලුවන්. ඒ වගේම performance සහ scalability එක වැඩි වෙනවා. ඒ වගේම අපේ විවිද use case වලට ගැලපෙන executors කීපයක්ම තියෙනවා.
🔹 Executors.newSingleThreadExecutor() – for sequential task ex*****on.
🔹Executors.newFixedThreadPool(n) – for a fixed number of threads.
🔹Executors.newCachedThreadPool() – for dynamic thread management.
Real world usage එක ගැන බැලුවොත් අපිට background timers වගේ light-weight, single purpose scenario වලට threads use කරන්න පුලුවන්. Web server එකක multiple client request handle කරන්න, microservices වලදි worker tasks manage කරන්න, spring boot / Java EE වගේ framework වලදි parallel computations කරන්න වගේ වැඩ වලට අපිට executors use කරන්න පුලුවන්.
මේ වගේ තව article එකකින් අපි වෙන දවසක හම්බ වෙමු.
21/10/2025
Java Concept Breakdown Article Series එකෙන් අද අපි බලමු Java වල Annotations සහ ඒවා internally වැඩ කරන්නෙ කොහොමද කියලා.
මුලින්ම annotations introduce කරේ JDK 5 වලදි. මේ annotations වලින් අපේ code එකේ metadata තියාගන්නවා. මේ metadata, compiler එකට හෝ runtime එකේදි වැදගත් වෙනවා. Annotations, simple markers වගේ පෙනුනට Spring, Hibernate වගේ framework වලදි ලොකු role එකක් play කරනවා.
🍀 What are Annotations ?
මුලින්ම කිව්වා වගේ annotations කියන්නේ logic එක change කරන්නෙ නැතුව අපේ code එක ගැන addition information (metadata) provide කරන special tags. මේවා අපිට classes, methods, fields, parameters වලට වගේම package වලටත් apply කරන්න පුලුවන්. , , කියන්නෙ මේ විදියට අපි බහුලව use කරන annotations ටිකක්. මේ annotations, compiler එකට understand කරගන්න පුලුවන් built-in annotations. හැබැයි අපිට ඕන නම් custom annotations හදාගන්නත් පුලුවන්.
🍀How Annotations Work Internally ?
Technically, annotation එකක් කියන්නෙ java.lang.annotation.Annotation interface එක extend කරලා තියෙන interface එකක්. Compiler එකට මේ annotation එකක් meet උනාම bytecode එක හරහා metadata, .class file එකට embed කරනවා.
Runtime එකේදි JVM එකට, Class.getAnnotations(), Method.getAnnotation() වගේ methods use කරලා reflection හරහා මේ annotations access කරන්න පුලුවන්.
මේ annotations වල visibility එක retention policy මත depend වෙනවා.
🔹 SOURCE: Discarded after compilation (used by tools like Lombok).
🔹CLASS: Stored in bytecode but ignored at runtime (default behavior).
🔹RUNTIME: Retained in the class file and accessible during runtime (used by frameworks like Spring and Hibernate).
🍀The Role of Annotation Processors
Java වල තියෙන Annotation Processing Tool (APT) එකෙන් compilation එකේදි source code එක scan කරන්නත්, additional files or configuration generate කරන්නත් පුලුවන්.
උදාහරණයක් විදියට MapStruct, Dragger වගේ frameworks මේ annotation processor එක use කරලා boilerplate code automatically generate කරනවා.
🍀Why Annotations Matter
Annotations use කරලා අපිට code එකේ readability එක වැඩි කරන්න, boilerplate code අඩු කරන්න වගේම සමහර powerful runtime behaviors enable කරන්න පුලුවන්.
මේ වගේ තව article එකකින් අපි වෙන දවසක හම්බ වෙමු.
14/10/2025
Java Concept Breakdown Article Series එකෙන් අද අපි බලමු interview වලදි තවත් ගොඩක් වැදගත් topic එකක් වන Java වල ThreadLocal ගැන.
අපි Multi threaded application වල වැඩ කරනකොට එන ලොකු challenge එකක් තමයි shared data safely manage කරන එක. ගොඩක් වෙලාවට අපිට අනෙක් threads වල operation වලට interfere වෙන්නෙ නැතුව variables access කරන්න ඕන වෙනවා. මෙන්න මෙතනදි තමයි TheadLocal උදව් වෙන්නෙ.
🍀 What is ThreadLocal?
ThreadLocal class එක use කරලා අපිට thread-local variables හදන්න පුලුවන්. මේ variable එකේ තියෙන advantage එක තමයි මේ variable එක access කරන සෑම thread එකකටම copy එක ගානෙ තියෙනවා. සෑම thread එකක්ම වැඩ කරන්නෙ ඒ variable එකේ own copy එකක. ඒ කියන්නෙ මේ variable එක isolate වෙලා තියෙන්නෙ. එතකොට එක thread එකකින් කරන change එකක් අනෙක් threads වලට visible නෑ. සරලවම මේක JVM එකෙන් manage කරන threads වල private storage area එකක් වගේ.
🍀 How it Works?
Thread එකක් ThreadLocal variable එකකට read or write කරනකොට shared object එකක් එක්ක interact වෙන්නෙ නෑ. ඒ වෙනුවට own thread context එකක store වෙලා තියෙන value තමයි access කරන්නෙ. ඒක නිසා synchronization ඕන වෙන්නෙ නෑ. ඒ වගේම thread එක execute වෙලා ඉවර උනාම මේ data, garbage collect වෙනවා.
🍀 Why use ThreadLocal ?
Multi threaded application වලදි shared object වල thread safety එක ensure කරන්න synchronization ඕන වෙනවා. මේක අමතර complexity එකක් add කරනව වගේම slow performance වලට හේතු වෙන්න පුලුවන්. අපි ThreadLocal use කරාම synchronization ඕන වෙන්නෙ නෑ.
අපි දැන් බලමු ThreadLocal වල real world use cases ටිකක්.
1. User Sessions in Web Application : Server side framework වලදි සෑම request එකක්ම run වෙන්නෙ separate thread එකක. මේ වගේ වෙලාවට user specific data store කරන්න ThreadLocal use කරන්න පුලුවන්.
2. Database Connection Management : Hibernate වගේ framework වලදි database connection or transaction context store කරන්න ThreadLocal use වෙනවා.
3. Date Formatting : SimpleDateFormat වගේ classes, thread-safe නෑ. මේ වෙනුවට අපිට ThreadLocal use කරන්න පුලුවන්. එතකොර threads වලට own formatter instance එකක් maintain කරන්න පුලුවන්.
මේ වගේ තව article එකකින් අපි වෙන දවසක හම්බ වෙමු.
06/10/2025
Java Concept Breakdown Article Series එකෙන් අද අපි බලමු interview වලදි තවත් ගොඩක් වැදගත් topic එකක් වන Synchronization vs Locking ගැන.
Multi-threaded application වලදි variables, files, database connections වගේ shared resources, threads කීපයක් මගින් access කරනවා. මෙතනදි proper control එකක් නැති උනොත් data inconsistencies, race condition වගේ දේවල් වෙන්න පුලුවන්. මෙන්න මේ situation එක handle කරන්න Java වලදි key mechanism දෙකක් තියෙනවා.
1. Synchronization
2. Locking
🍀 What is Synchronization ?
Synchronization කියන්නෙ Java වලදි shared resources access control කරන්න තියෙන built-in mechanism එකක්. අපි synchronized keyword එක use කරලා මේක implement කරනවා.
Thread එකක් synchronized block or method එකකට enter උනාම ඒ object or class එක මත intrinsic lock (monitor lock) එකක් acquire කරගන්නවා. එතකොට තව thread එකක් මේ same synchronized section එක access කරන්න නම් අර lock එක release වෙනකන් ඉන්න ඕන. මේ නිසා atomicity වගේම visibility එක ensure වෙනවා.
Advantages:
1. Simple and easy to use
2. Automatically handles locking and unlocking
3. Ensures consistency and visibility
Limitations:
1. All threads trying to access the synchronized section get blocked, leading to performance bottlenecks.
2. No control over waiting, fairness, or interruption.
3. Can cause deadlocks if used carelessly across multiple resources.
What is Locking?
Synchronization mechanism එකේ තියෙන සමහර limitations overcome කරන්න Java වලින් Lock API එක introduce කරලා තියෙනවා. Synchronization වලදි JVM එක මගින් locks automatically handle කරනවා. හැබැයි Lock API එකෙන් lock එක acquire වෙන්න ඕන විදිය release වෙන්න ඕන විදිය developer ට decide කරන්න පුලුවන්.
Advantages:
1. Fine-grained control over concurrency.
2. Better performance under heavy contention.
3. Ability to implement complex synchronization policies.
Limitations:
1. Must be manually unlocked. Missing an unlock call can lead to issues.
2. Slightly more complex and verbose code.
3. Improper use can lead to deadlocks or starvation.
🍀 Choosing the Right Mechanism
Synchronization සහ locking mechanism දෙකෙන් එකක් තෝරගන්න එක use case එක අනුව කරන්න ඕන. අපිට simple සහ contention එක low use case වලදි synchronization use කරන්න පුලුවන්.
Complex coordination or high concurrency scenarios වගේ performance and flexibility එක crucial situation වලදි Lock API එක use කරන්න පුලුවන්.
මේ වගේ තව article එකකින් අපි වෙන දවසක හම්බ වෙමු.
02/10/2025
Java Concept Breakdown Article Series එකෙන් අද අපි බලමු interview වලදි තවත් ගොඩක් වැදගත් topic එකක් වන String Pool & Interning ගැන.
🌿 What is the String Pool?
String pool එක කියන්නෙ unique string literals store වෙලා තියෙන heap memory එකේ reserved area එකක්. අපි string literal එකක් create කරාම මුලින්ම මේ string pool එක check වෙනවා. අපි create කරපු string literal එක already string pool එකේ තිබුනොත් ඒකේ reference එක reuse වෙනවා. String pool එකේ අපි create කරන string literal එක නැත්නම් ඒක pool එකට add වෙනවා.
මේ mechanism එක නිසා duplicate string instances create වෙන්නෙ නෑ. ඒ වෙනුවට එක string literal එකකට reference කීපයක් point කරන්න පුලුවන්. මේ නිසා memory overhead එක අඩු වෙනවා.
🌿What is String Interning ?
Distinct string value වලින් එක copy එකක් විතරක් string pool එකේ store කරන process එක අපි string interning කියලා හදුන්වනවා. මේක manage කරන්නෙ intern() method එකෙන්. String එක pool එකේ already තියෙනවනම් මේ intern() method එකෙන් අදාල reference එක return කරනවා. String එක pool එකේ නැත්නම් pool එකට add කරලා reference එක return කරනවා. මේ නිසා අපිට == (reference equality) use කරලා උනත් string compare කරගන්න පුලුවන්.
🌿Why Use the String Pool?
1. Memory Efficiency - Duplicate string object create වෙන එක වලක්වනවා.
2. Performance - Interned Strings use කරාම string comparison එක ටිකක් fast.
3. Reusability - Application එක පුරාම use වෙලා තියෙන strings, එක memory location එකකින් reference කරන්න පුලුවන්.
🌿Key Considerations
1. අපි string literal එකක් create කරාම ඒක automatically, string pool එකට යනවා.
2. new String() use කරලා අපි string එකක් create කරොත් ඒක store වෙන්නෙ heap එකේ. String pool එකේ නෙවේ. හැබැයි intern() method එක use කරලා අපිට pool එකට ගන්න පුලුවන්.
3. Large system වලදි intern() method එක overuse කරොත් ඒක නිසා pool area එකේ memory pressure එක වැඩි වෙන්න පුලුවන්. ඒක නිසා මේක carefully කරන්න ඕන.
මේ වගේ තව article එකකින් අපි වෙන දවසක හම්බ වෙමු.
30/09/2025
Java Concept Breakdown Article Series එකෙන් අද අපි බලමු interview වලදි තවත් ගොඩක් වැදගත් topic එකක් වන Volatile සහ Synchronized keywords ගැන.
Multi-threaded application එකක් develop කරනකොට threads වලින් shared data access and update කරන විදිය manage කරන එක critical. මේකට commonly use කරන tool දෙකක් තමයි volatile keyword එක සහ synchronized block / method. මේ දෙකම thread safety ensure කරන්න use කරාට, use කරන purpose වෙනස්.
🍀 What is Volatile ?
Threads කීපයක් මගින් value එක modify වෙන variables declare කරන්න අපි volatile keyword එක use කරනවා. Volatile keyword එක use කරලා declare කරන variable එකක් එක thread එකකින් update කරාම ඒ change එක immediately අනෙක් threads වලට visible වෙනවා (ensures visibility). මේකෙදි threads වලින් variable එකේ value එක cache වෙන එක වලක්වනවා. හැබැයි atomicity ensure වෙන්නෙ නෑ (No guarantee against race conditions).
🍀What is Synchronized?
Synchronized keyword එකෙන් visibility එක වගේම atomicity එකත් ensure කරනවා. අපි synchronized keyword එක use කරලා code block එකක් හෝ method එකක් declare කරාම ඒක වෙලාවකදි ඒක execute කරන්න පුලුවන් එක thread එකකට විතරයි (mutual exclusion). ඒක නිසා race conditions prevent වෙනවා. Synchronized block එක execute වෙලා ඉවර උනාම changes අනෙක් threads වලට visible වෙනවා. Lock එක acquire කරගන්න thread වලට wait වෙන්න වෙන නිසා මෙතනදි පොඩි performance overhead එකක් තියෙනවා.
🍀Volatile in Practice
Status flags or configuration updates වගේ atomic operations required නැති use cases වලට අපි volatile keyword එක ගොඩක් use කරනවා.
🍀Synchronized in Practice
Bank transactions, thread-safe collection වගේ operations කීපයක් safely perform කරන්න ඕන අවස්තා වල අපි synchronized keyword එක use කරනවා. උදාහරණයක් විදියට account balance එක update කරනකොට ,
1. Read current balance
2. Subtract amount
3. Update new balance
වගේ operations කීපයක් තියෙනවා. මේ වගේ වෙලාවට synchronized keyword එක suitable.
මේ වගේ තව article එකකින් අපි වෙන දවසක හම්බ වෙමු.
25/09/2025
Java interview වල ගොඩක් වැදගත් වන Immutable Objects සහ performance වලට immutable objects වලින් තියෙන impact එක ගැන අද අපි බලමු.
🌿 What Are Immutable Objects?
Java වල immutable objects කියලා consider කරන්නෙ create කරාට පස්සෙ state එක change කරන්න බැරි objects. මේ වගේ object එකකට change එකක් කරාම existing object එක modify වෙනවා වෙනුවට අලුත් එකක් create වෙනවා. මේකට හොදම උදාහරණයක් තමයි String class එක. String එකකට අපි change එකක් කරාම තියෙන original string එක modify වෙනවා වෙනුවට අලුතෙන් string එකක් create වෙනවා.
🌿Characteristics of Immutability
Immutability nature එක achieve කරන්න නම් object එක create කරනකොට state එක fixed වෙන්න ඕන. ඒ කියන්නෙ object එක setter expose කරන්නෙ නෑ. ඒ වගේම fields, reassign වෙන්න බෑ. මොනවහරි references hold කරන් ඉන්නවනම් ඒවා externally change වෙන්නත් බෑ.
🌿Performance Benefits
1. මේ objects, thread-safe. Synchronisation එකක් නැතුව threads අතරෙ share කරන්න පුලුවන්.
2. State එක change වෙන්නෙ නැති නිසා caching වලට use කරන්න පුලුවන්.
3. Unexpected modifications වෙන්නෙ නැති නිසා debugging වලදි ගොඩක් ලේසි.
🌿Performance Drawbacks
1. සෑම modification එකකින්ම අලුත් object එකක් create වෙන නිසා memory usage එක increase වෙනවා.
2. Modification heavy scenario වලදි garbage collection activities වැඩී. මේ වගේ වෙලාවට builders වගේ mutable alternatives ගොඩක් efficient.
🌿Real-World Usage
1. String, Integer, Long, BigDecimal වගේ core classes, immutable.
2. Multi-threaded application වලදි synchronisation overhead එක eliminate කරන්න අපිට මේක use කරන්න පුලුවන්.
3. Functional programming වලදි streams සහ lambdas එක්ක, immutable nature එක නිසා safe parallel ex*****on එකක් ensure කරන්න පුලුවන්.
4. Stable hash values ඕන වෙන caching framework වල widely use වෙනවා.
5. Sensitive data, malicious changes වලින් protect කරගන්නත් use කරන්න පුලුවන්.
මේ වගේ තව article එකකින් අපි වෙන දවසක හම්බ වෙමු.
23/09/2025
අපේ DSA Questions discuss කරන article series එකෙන් අද අපි බලන්නෙ ගොඩක් common question එකක්.
Question එක තමයි given string එකක් palindrome string එකක්ද කියලා check කරන්න function එකක් ලියන එක. Palindrome word එකක් කියන්නෙ Bob, Civic වගේ backwards read කරත් forward read කරන අකුරු පිලිවෙලම තියෙන වචන.
Example 1:
Input: "madam"
Output: true
Example 2:
Input: "hello"
Output: false
මේකටත් naive සහ optimized approach දෙකක් තියෙනවා. Naive approach එක තමයි String එක reverse කරලා ඒක original string එකට equal ද කියලා බලන එක. මේකෙදි අපි අලුතෙන් reverse string එකක් create කරන නිසා O(n) space complexity එකක් සහ O(n) time complexity එකක් තියෙනවා.
Optimized approach එකේදි left සහ right විදියට pointers දෙකක් use කරනවා. මේකෙදි මේ pointers දෙක, string එකේ center එකට move කරන ගමන් characters compare කරනවා. සේරම characters match උනොත් palindrome නිසා true return වෙනවා. නැත්නම් false. මේ approach එකේ time complexity එක O(n). Space complexity එක O(1).
ඔයාලගෙ ලග මීට වඩා වෙනස් approaches තියෙනවනම් ඒවත් comment කරන්න.
Click here to claim your Sponsored Listing.