<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gana Oyundalai on Medium]]></title>
        <description><![CDATA[Stories by Gana Oyundalai on Medium]]></description>
        <link>https://medium.com/@marvelous_brass_marten_205?source=rss-822939c20655------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KH5sv7Hsi7p-_xh9LRyObw.png</url>
            <title>Stories by Gana Oyundalai on Medium</title>
            <link>https://medium.com/@marvelous_brass_marten_205?source=rss-822939c20655------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 23:50:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marvelous_brass_marten_205/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Popular Movies App with Jetpack Compose, Retrofit & Room]]></title>
            <link>https://medium.com/@marvelous_brass_marten_205/building-popular-movies-app-with-jetpack-compose-retrofit-room-c47c30a17677?source=rss-822939c20655------2</link>
            <guid isPermaLink="false">https://medium.com/p/c47c30a17677</guid>
            <category><![CDATA[retrofit]]></category>
            <dc:creator><![CDATA[Gana Oyundalai]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 04:50:36 GMT</pubDate>
            <atom:updated>2026-09-16T04:50:36.448Z</atom:updated>
            <content:encoded><![CDATA[<p>🔗 <strong>Source code:</strong> <a href="https://github.com/oganaa2472/movie_app">https://github.com/oganaa2472/movie_app</a></p><p>This project demonstrates a simple, pragmatic architecture for a movies list app using Kotlin, Jetpack Compose, Retrofit and Room. The app fetches “Most Popular” movies from The Movie Database (TMDB), caches results in a local Room database, and falls back to the cached data when offline.</p><h3>Who is this for</h3><ul><li>Target audience: intermediate Android developers who know Kotlin and Compose and want a concise example of combining networking + local caching with MVVM.</li><li>Post type: code walkthrough + how-to run.</li></ul><h3>Tech stack at a glance</h3><ul><li>Kotlin</li><li>Jetpack Compose (UI)</li><li>Retrofit (networking)</li><li>Room (local caching)</li><li>Coroutines (asynchronous work)</li><li>Coil (image loading)</li></ul><h3>Project structure (simple)</h3><p>Key folders (under app/src/main/java/com/example/movizapp):</p><ul><li>retrofit/ – Retrofit models and service</li><li>room/ – Room entity, DAO and database</li><li>repository/ – single source of truth for data</li><li>viewmodel/ – ViewModel exposing UI state</li><li>screens/ – Compose UI (list, item, screen)</li></ul><h3>Architecture summary</h3><p>The app follows MVVM:</p><ul><li>Repository handles data fetching from Retrofit and reading/writing Room.</li><li>ViewModel launches a coroutine: it tries to fetch from the network, saves to Room and updates UI state; on failure it loads data from Room.</li><li>Compose UI observes ViewModel state (a List&lt;Movie&gt;) and displays it.</li></ul><p>This is a pragmatic offline-first strategy: attempt online, then fallback to local cache.</p><ol><li>Retrofit wiring (base URL + API)</li></ol><pre>object RetrofitInstance{<br>    private const val BASE_URL = &quot;https://api.themoviedb.org/3/&quot;<br>    val api: ApiService by lazy{<br>        val retrofit = Retrofit.Builder()<br>            .baseUrl(BASE_URL)<br>            .addConverterFactory(GsonConverterFactory.create())<br>            .build()</pre><pre>        retrofit.create(ApiService::class.java)<br>    }<br>}</pre><p>ApiService defines the movie/popular endpoint and expects an API key as a query parameter.</p><ol><li>Room entity &amp; database</li></ol><pre>@Entity(tableName = &quot;movies_table&quot;)<br>data class Movie(<br>    @PrimaryKey val id: Int,<br>    val title: String,<br>    val overview: String,<br>    val poster_path: String<br>)</pre><pre>@Database(entities = [Movie::class], version = 1)<br>abstract class MoviesDb: RoomDatabase() {<br>    abstract val moviesDao: MovieDAO<br>     companion object {<br>        @Volatile<br>        private var INSTANCE:MoviesDb? = null<br>        fun getInstance(context: Context): MoviesDb{<br>            synchronized(this){<br>                var instance = INSTANCE<br>                if(instance==null){<br>                    instance= Room.databaseBuilder(<br>                        context = context.applicationContext,<br>                        MoviesDb::class.java,<br>                        &quot;movies_db&quot;<br>                    ).build()<br>                }<br>                INSTANCE = instance<br>                return instance<br>            }<br>        }</pre><pre>    }</pre><ol><li>Repository (network + db operations)</li></ol><pre>class MovieRepository(context: Context) {<br>    suspend fun getPopularMoviesFromOnlineApi(apiKey: String): List&lt;Movie&gt; =<br>        RetrofitInstance.api.getPopularMovies(apiKey).results</pre><pre>    suspend fun getMoviesFromDb(): List&lt;Movie&gt; = movieDao.getAllMoviesInDB()<br>    suspend fun insertMoviesIntoDB(movies: List&lt;Movie&gt;) = movieDao.insertMoviesList(movies)<br>}</pre><ol><li>ViewModel fallback logic (simplified)</li></ol><pre>init {<br>    viewModelScope.launch {<br>        try {<br>            moviesFromApi = repository.getPopularMoviesFromOnlineApi(&quot;&quot;)<br>            repository.insertMoviesIntoDB(moviesFromApi)<br>            movies = moviesFromApi<br>        } catch (e: Exception) {<br>            moviesFromRoomDb = repository.getMoviesFromDb()<br>            movies = moviesFromRoomDb<br>        }<br>    }<br>}</pre><p>Note: the code currently passes an empty string for the API key in the ViewModel. Add your TMDB API key in <a href="http://local.properties/">local.properties</a> and pass it to the repository (instructions below).</p><ol><li>Compose UI</li></ol><p>The UI uses LazyColumn + Card for each MovieItem. Images are loaded via Coil&#39;s AsyncImage and the movie title + overview are shown in a Column.</p><h3>How to run</h3><ol><li>Clone the repository and open it in Android Studio.</li><li>Add your TMDB API key to <a href="http://local.properties/">local.properties</a> (project root):</li></ol><pre>API_KEY=your_tmdb_api_key_here</pre><ol><li>Make sure the ViewModel reads that property (for example via BuildConfig or passing it from MainActivity). If you prefer a quick test, you can hardcode the key while developing — but do not commit it.</li><li>Build and run from Android Studio, or from the terminal (macOS / zsh):</li></ol><pre>./gradlew assembleDebug</pre><p>Open the app on a device or emulator. If online, the app will fetch the popular movies and cache them to Room. If offline it will show the cached list.</p><h3>Limitations &amp; suggested improvements</h3><ul><li>API key handling: currently the key isn’t wired into MovieViewModel (it uses an empty string). Pass the key securely (BuildConfig, or via DI) and avoid hardcoding.</li><li>Error handling &amp; UX: surface network errors with a retry button and show loading / empty states in the UI.</li><li>Paging: for large result sets, integrate Android Paging 3 to load pages from network and db.</li><li>Dependency Injection: add Hilt to manage repository and ViewModel lifecycle and simplify testing.</li><li>Tests: add unit tests for MovieRepository (using a fake ApiService) and UI tests for Compose screens.</li><li>Caching policy: add timestamps and an eviction policy for stale data.</li></ul><h3>Lessons learned</h3><ul><li>Compose + State makes wiring UI to ViewModel simple: a single movies: List&lt;Movie&gt; state updates UI reactively.</li><li>Room + Retrofit together give a smooth offline experience with minimal glue code.</li><li>Keep networking code small and testable by isolating Retrofit + DTOs in one package and mapping as needed before storing in the DB.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c47c30a17677" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Notes App with Jetpack Compose, Room & Hilt]]></title>
            <link>https://medium.com/@marvelous_brass_marten_205/simple-notes-app-with-jetpack-compose-room-hilt-fd9670c018d6?source=rss-822939c20655------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd9670c018d6</guid>
            <category><![CDATA[android-jetpack-compose]]></category>
            <dc:creator><![CDATA[Gana Oyundalai]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 04:44:52 GMT</pubDate>
            <atom:updated>2026-09-16T04:44:52.038Z</atom:updated>
            <content:encoded><![CDATA[<p>This small Android app demonstrates a clean, modern stack:Jetpack Compose for UI, Room for local persistence, and Hilt for dependency injection.The code is compact and organized into Application, data(Room), repository, ViewModel, and Compose UI layers- perfect as a learning example or starting point for a producition — readt notes app.</p><p>GitRepo : <a href="https://github.com/oganaa2472/notes_app/">https://github.com/oganaa2472/notes_app/</a></p><h3>What you’ll learn</h3><ul><li>How the app is structured (files &amp; MVVM architechture)</li><li>How Room, DAO and database are defined and used</li><li>How Hilt provides dependencies</li><li>How the VIewModel and repository connect the UI to the data layer</li><li>How a simple compose UI collects user input and displays notes</li></ul><h3>Project Overview</h3><p>This repository contains a single app module (app) implementing a basic notes application. Major files to inspect:</p><ul><li>MyApp.kt — Hilt-enabled Application class</li><li>MainActivity.kt — Compose host and entry point</li><li>Note.kt — Room entity for a note</li><li>NoteDao.kt — DAO with database operations</li><li>NoteDatabase.kt — Room database singleton</li><li>AppModule.kt — Hilt module to provide Room and DAO</li><li>NoteRepository.kt — Data abstraction over DAO</li><li>NoteViewModel.kt — Exposes flows and actions to UI</li><li>NoteScreen.kt &amp; NoteItem.kt — Compose UI for creating and listing notes</li></ul><p>This layering keeps UI, business logic, and persistence concerns separated and testable.</p><h3>Files &amp; key snippets explained</h3><h3>1) Application entry: MyApp.kt</h3><p>The application is annotated with Hilt to enable dependency injection across the app.</p><pre>@HiltAndroidApp<br>class MyApp: Application()</pre><p>This wire-up allows Hilt to inject dependencies into Activities, ViewModels, and other components.</p><h3>2) Main activity: MainActivity.kt</h3><p>A minimal Compose host that applies an app theme and loads NoteScreen.</p><pre>@AndroidEntryPoint<br>class MainActivity : ComponentActivity() {<br>  override fun onCreate(savedInstanceState: Bundle?) {<br>    super.onCreate(savedInstanceState)<br>    enableEdgeToEdge()<br>    setContent { NoteAppTheme { NoteScreen() } }<br>  }<br>}</pre><p>@AndroidEntryPoint allows Hilt to inject dependencies (for example ViewModels using Hilt).</p><h3>3) Data model: Note.kt</h3><p>A straightforward Room entity representing a note.</p><pre>@Entity(tableName = &quot;Notes&quot;)<br>data class Note(<br>  @PrimaryKey(autoGenerate = true) val id: Int = 0,<br>  val title: String,<br>  val content: String,<br>  val timestamp: Long<br>)</pre><p>The timestamp is used for ordering notes by recency.</p><h3>4) DAO: NoteDao.kt</h3><p>A DAO using Kotlin Flow to observe note lists:</p><pre>@Dao<br>interface NoteDao {<br>  @Insert suspend fun insert(note: Note)<br>  @Query(&quot;Select * from notes order by timestamp desc&quot;)<br>  fun getAllNotes(): Flow&lt;List&lt;Note&gt;&gt;<br>}</pre><p>Using Flow&lt;List&lt;Note&gt;&gt; makes UI reactive: updates are observed automatically.</p><p>Note: the SQL uses notes in lowercase while the entity tableName is Notes; Room is usually case-insensitive for table name mapping but it&#39;s good practice to keep the names consistent (e.g., both notes).</p><h3>5) Database singleton: NoteDatabase.kt</h3><p>A classic double-checked, synchronized singleton to create the Room database:</p><pre>@Database(entities = [Note::class], version = 1, exportSchema = false)<br>abstract class NoteDatabase: RoomDatabase() {<br>  abstract fun noteDao(): NoteDao</pre><pre>  companion object {<br>    @Volatile private var INSTANCE: NoteDatabase? = null<br>    fun getDatabase(context: Context): NoteDatabase {<br>      return INSTANCE ?: synchronized(this) {<br>        val instance = Room.databaseBuilder(<br>            context.applicationContext,<br>            NoteDatabase::class.java,<br>            &quot;notes_database&quot;<br>        ).build()<br>        INSTANCE = instance<br>        instance<br>      }<br>    }<br>  }<br>}</pre><p>This provides a thread-safe single database instance across the app.</p><h3>6) Hilt module: AppModule.kt</h3><p>Provides the database and DAO as singletons:</p><pre>@Module<br>@InstallIn(SingletonComponent::class)<br>object AppModule {<br>  @Provides @Singleton fun provideNotDatabase(@ApplicationContext context: Context): NoteDatabase =<br>    NoteDatabase.getDatabase(context)</pre><pre>  @Provides @Singleton fun provideNoteDao(noteDatabase: NoteDatabase) = noteDatabase.noteDao()<br>}</pre><p>Because these are singletons, they are shared across the app lifetime and can be injected into repositories and ViewModels.</p><h3>7) Repository: NoteRepository.kt</h3><p>A thin repository that wraps DAO calls. This isolates the rest of the app from direct DAO usage:</p><pre>class NoteRepository @Inject constructor(private val noteDoa: NoteDao) {<br>  suspend fun insertNote(note: Note) { noteDoa.insert(note) }<br>  val allNotesInDb: Flow&lt;List&lt;Note&gt;&gt; = noteDoa.getAllNotes()<br>}</pre><p>Note: a small typo noteDoa — consider renaming to noteDao for clarity.</p><h3>8) ViewModel: NoteViewModel.kt</h3><p>Exposes the Flow of notes to the UI and a method to insert notes:</p><pre>@HiltViewModel<br>class NoteViewModel @Inject constructor(private val repo: NoteRepository): ViewModel() {<br>  val allNotes: Flow&lt;List&lt;Note&gt;&gt; = repo.allNotesInDb<br>  fun insert(note: Note) = viewModelScope.launch { repo.insertNote(note) }<br>}</pre><p>viewModelScope ensures DB operations run off the main thread.</p><h3>9) Compose UI: NoteScreen.kt &amp; NoteItem.kt</h3><p>The NoteScreen collects title/content via TextFields, inserts a new Note on Button click, and lists notes with LazyColumn:</p><pre>val notes by viewModel.allNotes.collectAsState(emptyList())</pre><pre>var title by remember { mutableStateOf(&quot;&quot;) }<br>var content by remember { mutableStateOf(&quot;&quot;) }</pre><pre>Button(onClick = {<br>  viewModel.insert(Note(0, title, content, System.currentTimeMillis()))<br>  title = &quot;&quot;<br>  content = &quot;&quot;<br>}) { Text(&quot;Add note&quot;) }</pre><pre>LazyColumn { items(notes) { note -&gt; NoteItem(note) } }</pre><p>And NoteItem renders a card with title and content:</p><pre>@Composable<br>fun NoteItem(note: Note) {<br>  Card(modifier = Modifier.fillMaxWidth().padding(8.dp)) {<br>    Column(modifier = Modifier.padding(16.dp)) {<br>      Text(note.title, style = MaterialTheme.typography.titleMedium)<br>      Text(note.content, style = MaterialTheme.typography.bodyMedium)<br>    }<br>  }<br>}</pre><p>This Compose UI is compact and idiomatic: state hoisted into local remember variables, collectAsState to subscribe to the Flow, and a LazyColumn for performance.</p><h3>Design choices &amp; rationale</h3><ul><li>Room + Flow: keeps UI reactive and avoids manual refresh logic.</li><li>Hilt: simple DI for singletons (DB/DAO) and ViewModel injection.</li><li>Repository layer: separates data-source details from ViewModel (helps testing and future extension to remote sources).</li></ul><p>Compose UI: minimal, clean, and modern Android UI toolkit.</p><h3>Small issues and recommended improvements</h3><ul><li>Table name consistency: @Entity(tableName = &quot;Notes&quot;) vs DAO query &quot;Select * from notes ...&quot;. Use consistent casing (e.g., notes) to avoid confusion.</li><li>DAO query ordering: good use of timestamp desc, but consider storing updatedAt vs createdAt to manage edits.</li><li>Deletions/updates: currently only insertion and listing are implemented. Add @Update and @Delete methods in NoteDao and corresponding UI actions.</li><li>Error handling &amp; validation: validate empty title/content, and show user feedback (snackbar/toast) on success/failure.</li><li>Migration strategy: the database uses version 1 with no migration. For production, either add migrations or use fallbackToDestructiveMigration() carefully in dev only.</li><li>Tests: add unit tests for repository and ViewModel, and instrumented tests for DAO using an in-memory Room database.</li></ul><h3>How to run locally</h3><p>From project root (macOS / zsh):</p><pre>./gradlew assembleDebug<br># install on a connected device/emulator:<br>./gradlew installDebug</pre><p>Or open the project in Android Studio and run the app configuration.</p><h3>Conclusion</h3><p>This NoteApp is a compact, practical demonstration of modern Android development: Jetpack Compose for a declarative UI, Room for reliable local persistence, and Hilt for simple, testable dependency injection. The project shows how a small, well-layered architecture keeps concerns separated — UI, ViewModel, repository, and data — making the app easy to reason about, extend, and test.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd9670c018d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Notes App with Jetpack Compose, Room and Hilt]]></title>
            <link>https://medium.com/@marvelous_brass_marten_205/building-notes-app-with-jetpack-compose-room-and-hilt-42e3dc26c7ed?source=rss-822939c20655------2</link>
            <guid isPermaLink="false">https://medium.com/p/42e3dc26c7ed</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[dagger-hilt]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[room-database]]></category>
            <dc:creator><![CDATA[Gana Oyundalai]]></dc:creator>
            <pubDate>Mon, 19 Jan 2026 20:43:40 GMT</pubDate>
            <atom:updated>2026-01-19T20:59:53.522Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NkV7baNm3b4sluPWi9XuQ.jpeg" /></figure><p>This small Android app demonstrates a clean, modern stack:Jetpack Compose for UI, Room for local persistence, and Hilt for dependency injection.The code is compact and organized into Application, data(Room), repository, ViewModel, and Compose UI layers- perfect as a learning example or starting point for a producition — readt notes app.</p><p>GitRepo : <a href="https://github.com/oganaa2472/notes_app/">https://github.com/oganaa2472/notes_app/</a></p><h3>What you’ll learn</h3><ul><li>How the app is structured (files &amp; MVVM architechture)</li><li>How Room, DAO and database are defined and used</li><li>How Hilt provides dependencies</li><li>How the VIewModel and repository connect the UI to the data layer</li><li>How a simple compose UI collects user input and displays notes</li></ul><h3>Project Overview</h3><p>This repository contains a single app module (app) implementing a basic notes application. Major files to inspect:</p><ul><li>MyApp.kt — Hilt-enabled Application class</li><li>MainActivity.kt — Compose host and entry point</li><li>Note.kt — Room entity for a note</li><li>NoteDao.kt — DAO with database operations</li><li>NoteDatabase.kt — Room database singleton</li><li>AppModule.kt — Hilt module to provide Room and DAO</li><li>NoteRepository.kt — Data abstraction over DAO</li><li>NoteViewModel.kt — Exposes flows and actions to UI</li><li>NoteScreen.kt &amp; NoteItem.kt — Compose UI for creating and listing notes</li></ul><p>This layering keeps UI, business logic, and persistence concerns separated and testable.</p><h3>Files &amp; key snippets explained</h3><h3>1) Application entry: MyApp.kt</h3><p>The application is annotated with Hilt to enable dependency injection across the app.</p><pre>@HiltAndroidApp<br>class MyApp: Application()</pre><p>This wire-up allows Hilt to inject dependencies into Activities, ViewModels, and other components.</p><h3>2) Main activity: MainActivity.kt</h3><p>A minimal Compose host that applies an app theme and loads NoteScreen.</p><pre>@AndroidEntryPoint<br>class MainActivity : ComponentActivity() {<br>  override fun onCreate(savedInstanceState: Bundle?) {<br>    super.onCreate(savedInstanceState)<br>    enableEdgeToEdge()<br>    setContent { NoteAppTheme { NoteScreen() } }<br>  }<br>}</pre><p>@AndroidEntryPoint allows Hilt to inject dependencies (for example ViewModels using Hilt).</p><h3>3) Data model: Note.kt</h3><p>A straightforward Room entity representing a note.</p><pre>@Entity(tableName = &quot;Notes&quot;)<br>data class Note(<br>  @PrimaryKey(autoGenerate = true) val id: Int = 0,<br>  val title: String,<br>  val content: String,<br>  val timestamp: Long<br>)</pre><p>The timestamp is used for ordering notes by recency.</p><h3>4) DAO: NoteDao.kt</h3><p>A DAO using Kotlin Flow to observe note lists:</p><pre>@Dao<br>interface NoteDao {<br>  @Insert suspend fun insert(note: Note)<br>  @Query(&quot;Select * from notes order by timestamp desc&quot;)<br>  fun getAllNotes(): Flow&lt;List&lt;Note&gt;&gt;<br>}</pre><p>Using Flow&lt;List&lt;Note&gt;&gt; makes UI reactive: updates are observed automatically.</p><p>Note: the SQL uses notes in lowercase while the entity tableName is Notes; Room is usually case-insensitive for table name mapping but it&#39;s good practice to keep the names consistent (e.g., both notes).</p><h3>5) Database singleton: NoteDatabase.kt</h3><p>A classic double-checked, synchronized singleton to create the Room database:</p><pre>@Database(entities = [Note::class], version = 1, exportSchema = false)<br>abstract class NoteDatabase: RoomDatabase() {<br>  abstract fun noteDao(): NoteDao</pre><pre>  companion object {<br>    @Volatile private var INSTANCE: NoteDatabase? = null<br>    fun getDatabase(context: Context): NoteDatabase {<br>      return INSTANCE ?: synchronized(this) {<br>        val instance = Room.databaseBuilder(<br>            context.applicationContext,<br>            NoteDatabase::class.java,<br>            &quot;notes_database&quot;<br>        ).build()<br>        INSTANCE = instance<br>        instance<br>      }<br>    }<br>  }<br>}</pre><p>This provides a thread-safe single database instance across the app.</p><h3>6) Hilt module: AppModule.kt</h3><p>Provides the database and DAO as singletons:</p><pre>@Module<br>@InstallIn(SingletonComponent::class)<br>object AppModule {<br>  @Provides @Singleton fun provideNotDatabase(@ApplicationContext context: Context): NoteDatabase =<br>    NoteDatabase.getDatabase(context)</pre><pre>  @Provides @Singleton fun provideNoteDao(noteDatabase: NoteDatabase) = noteDatabase.noteDao()<br>}</pre><p>Because these are singletons, they are shared across the app lifetime and can be injected into repositories and ViewModels.</p><h3>7) Repository: NoteRepository.kt</h3><p>A thin repository that wraps DAO calls. This isolates the rest of the app from direct DAO usage:</p><pre>class NoteRepository @Inject constructor(private val noteDoa: NoteDao) {<br>  suspend fun insertNote(note: Note) { noteDoa.insert(note) }<br>  val allNotesInDb: Flow&lt;List&lt;Note&gt;&gt; = noteDoa.getAllNotes()<br>}</pre><p>Note: a small typo noteDoa — consider renaming to noteDao for clarity.</p><h3>8) ViewModel: NoteViewModel.kt</h3><p>Exposes the Flow of notes to the UI and a method to insert notes:</p><pre>@HiltViewModel<br>class NoteViewModel @Inject constructor(private val repo: NoteRepository): ViewModel() {<br>  val allNotes: Flow&lt;List&lt;Note&gt;&gt; = repo.allNotesInDb<br>  fun insert(note: Note) = viewModelScope.launch { repo.insertNote(note) }<br>}</pre><p>viewModelScope ensures DB operations run off the main thread.</p><h3>9) Compose UI: NoteScreen.kt &amp; NoteItem.kt</h3><p>The NoteScreen collects title/content via TextFields, inserts a new Note on Button click, and lists notes with LazyColumn:</p><pre>val notes by viewModel.allNotes.collectAsState(emptyList())</pre><pre>var title by remember { mutableStateOf(&quot;&quot;) }<br>var content by remember { mutableStateOf(&quot;&quot;) }</pre><pre>Button(onClick = {<br>  viewModel.insert(Note(0, title, content, System.currentTimeMillis()))<br>  title = &quot;&quot;<br>  content = &quot;&quot;<br>}) { Text(&quot;Add note&quot;) }</pre><pre>LazyColumn { items(notes) { note -&gt; NoteItem(note) } }</pre><p>And NoteItem renders a card with title and content:</p><pre>@Composable<br>fun NoteItem(note: Note) {<br>  Card(modifier = Modifier.fillMaxWidth().padding(8.dp)) {<br>    Column(modifier = Modifier.padding(16.dp)) {<br>      Text(note.title, style = MaterialTheme.typography.titleMedium)<br>      Text(note.content, style = MaterialTheme.typography.bodyMedium)<br>    }<br>  }<br>}</pre><p>This Compose UI is compact and idiomatic: state hoisted into local remember variables, collectAsState to subscribe to the Flow, and a LazyColumn for performance.</p><h3>Design choices &amp; rationale</h3><ul><li>Room + Flow: keeps UI reactive and avoids manual refresh logic.</li><li>Hilt: simple DI for singletons (DB/DAO) and ViewModel injection.</li><li>Repository layer: separates data-source details from ViewModel (helps testing and future extension to remote sources).</li></ul><p>Compose UI: minimal, clean, and modern Android UI toolkit.</p><h3>Small issues and recommended improvements</h3><ul><li>Table name consistency: @Entity(tableName = &quot;Notes&quot;) vs DAO query &quot;Select * from notes ...&quot;. Use consistent casing (e.g., notes) to avoid confusion.</li><li>DAO query ordering: good use of timestamp desc, but consider storing updatedAt vs createdAt to manage edits.</li><li>Deletions/updates: currently only insertion and listing are implemented. Add @Update and @Delete methods in NoteDao and corresponding UI actions.</li><li>Error handling &amp; validation: validate empty title/content, and show user feedback (snackbar/toast) on success/failure.</li><li>Migration strategy: the database uses version 1 with no migration. For production, either add migrations or use fallbackToDestructiveMigration() carefully in dev only.</li><li>Tests: add unit tests for repository and ViewModel, and instrumented tests for DAO using an in-memory Room database.</li></ul><h3>How to run locally</h3><p>From project root (macOS / zsh):</p><pre>./gradlew assembleDebug<br># install on a connected device/emulator:<br>./gradlew installDebug</pre><p>Or open the project in Android Studio and run the app configuration.</p><h3>Conclusion</h3><p>This NoteApp is a compact, practical demonstration of modern Android development: Jetpack Compose for a declarative UI, Room for reliable local persistence, and Hilt for simple, testable dependency injection. The project shows how a small, well-layered architecture keeps concerns separated — UI, ViewModel, repository, and data — making the app easy to reason about, extend, and test.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42e3dc26c7ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Clean Architecture Login Page in Flutter]]></title>
            <link>https://medium.com/@marvelous_brass_marten_205/clean-architecture-login-page-in-flutter-1df1ad166786?source=rss-822939c20655------2</link>
            <guid isPermaLink="false">https://medium.com/p/1df1ad166786</guid>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Gana Oyundalai]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 06:15:08 GMT</pubDate>
            <atom:updated>2025-07-23T06:15:08.577Z</atom:updated>
            <content:encoded><![CDATA[<h3>When building scalable Flutter apps, <strong>Clean Architecture</strong> ensures a clear separation of concerns. In this guide, we’ll implement a login page using:</h3><ul><li><strong>BLoC (Business Logic Component)</strong></li><li><strong>GetIt</strong> for dependency injection</li><li><strong>graphql_flutter</strong>: GraphQL client</li><li><strong>shared_preferences</strong>: Local storage</li><li><strong>equatable</strong>: Value equality</li><li><strong>dartz</strong>: Functional programming</li></ul><h3>🧱 Project Structure</h3><p>We’ll follow the classic clean architecture layers:</p><pre>lib/<br>├── core/<br>├── data/<br>├── domain/<br>├── presentation/<br>│   └── login/<br>├── main.dart</pre><h3>🔧 Step 1: Setup GetIt</h3><p>Install required dependencies in pubspec.yaml:</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  flutter_bloc: ^8.1.3<br>  get_it: ^7.6.0<br>  equatable: ^2.0.5</pre><p>Create core/di/service_locator.dart:</p><pre>import &#39;package:get_it/get_it.dart&#39;;<br>import &#39;../../data/repositories/auth_repository_impl.dart&#39;;<br>import &#39;../../domain/repositories/auth_repository.dart&#39;;<br>import &#39;../../domain/usecases/login_usecase.dart&#39;;<br>import &#39;../../presentation/login/bloc/login_bloc.dart&#39;;</pre><pre>final sl = GetIt.instance;</pre><pre>void init() {<br>  // BLoC<br>  sl.registerFactory(() =&gt; LoginBloc(sl()));</pre><pre>  // UseCases<br>  sl.registerLazySingleton(() =&gt; LoginUseCase(sl()));</pre><pre>  // Repositories<br>  sl.registerLazySingleton&lt;AuthRepository&gt;(() =&gt; AuthRepositoryImpl());<br>}</pre><h3>🧠 Step 2: Domain Layer</h3><h4>domain/entities/user.dart</h4><pre>class User {<br>  final String email;</pre><pre>  User({required this.email});<br>}</pre><h4>domain/repositories/auth_repository.dart</h4><pre>import &#39;../entities/user.dart&#39;;</pre><pre>abstract class AuthRepository {<br>  Future&lt;User&gt; login(String email, String password);<br>}</pre><h4>domain/usecases/login_usecase.dart</h4><pre>import &#39;../entities/user.dart&#39;;<br>import &#39;../repositories/auth_repository.dart&#39;;</pre><pre>class LoginUseCase {<br>  final AuthRepository repository;</pre><pre>  LoginUseCase(this.repository);</pre><pre>  Future&lt;User&gt; execute(String email, String password) {<br>    return repository.login(email, password);<br>  }<br>}</pre><h3>🗃️ Step 3: Data Layer</h3><h4>data/repositories/auth_repository_impl.dart</h4><pre>import &#39;../../domain/entities/user.dart&#39;;<br>import &#39;../../domain/repositories/auth_repository.dart&#39;;</pre><pre>class AuthRepositoryImpl implements AuthRepository {<br>  @override<br>  Future&lt;User&gt; login(String email, String password) async {<br>    // Simulated API call<br>    await Future.delayed(Duration(seconds: 2));<br>    return User(email: email);<br>  }<br>}</pre><h3>🎭 Step 4: Presentation Layer</h3><h4>presentation/login/bloc/login_event.dart</h4><pre>import &#39;package:equatable/equatable.dart&#39;;</pre><pre>abstract class LoginEvent extends Equatable {<br>  const LoginEvent();<br>}</pre><pre>class LoginButtonPressed extends LoginEvent {<br>  final String email;<br>  final String password;</pre><pre>  const LoginButtonPressed(this.email, this.password);</pre><pre>  @override<br>  List&lt;Object&gt; get props =&gt; [email, password];<br>}</pre><h4>presentation/login/bloc/login_state.dart</h4><pre>import &#39;package:equatable/equatable.dart&#39;;</pre><pre>abstract class LoginState extends Equatable {<br>  const LoginState();<br>  <br>  @override<br>  List&lt;Object?&gt; get props =&gt; [];<br>}</pre><pre>class LoginInitial extends LoginState {}</pre><pre>class LoginLoading extends LoginState {}</pre><pre>class LoginSuccess extends LoginState {}</pre><pre>class LoginFailure extends LoginState {<br>  final String message;</pre><pre>  const LoginFailure(this.message);</pre><pre>  @override<br>  List&lt;Object?&gt; get props =&gt; [message];<br>}</pre><h4>presentation/login/bloc/login_bloc.dart</h4><pre>import &#39;package:flutter_bloc/flutter_bloc.dart&#39;;<br>import &#39;login_event.dart&#39;;<br>import &#39;login_state.dart&#39;;<br>import &#39;../../../domain/usecases/login_usecase.dart&#39;;</pre><pre>class LoginBloc extends Bloc&lt;LoginEvent, LoginState&gt; {<br>  final LoginUseCase loginUseCase;</pre><pre>  LoginBloc(this.loginUseCase) : super(LoginInitial()) {<br>    on&lt;LoginButtonPressed&gt;((event, emit) async {<br>      emit(LoginLoading());<br>      try {<br>        await loginUseCase.execute(event.email, event.password);<br>        emit(LoginSuccess());<br>      } catch (e) {<br>        emit(LoginFailure(e.toString()));<br>      }<br>    });<br>  }<br>}</pre><h3>🖥️ Step 5: Login UI</h3><h4>presentation/login/login_page.dart</h4><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_bloc/flutter_bloc.dart&#39;;<br>import &#39;../../core/di/service_locator.dart&#39;;<br>import &#39;bloc/login_bloc.dart&#39;;<br>import &#39;bloc/login_event.dart&#39;;<br>import &#39;bloc/login_state.dart&#39;;</pre><pre>class LoginPage extends StatelessWidget {<br>  final TextEditingController emailController = TextEditingController();<br>  final TextEditingController passwordController = TextEditingController();</pre><pre>  LoginPage({super.key});</pre><pre>  @override<br>  Widget build(BuildContext context) {<br>    return BlocProvider(<br>      create: (_) =&gt; sl&lt;LoginBloc&gt;(),<br>      child: Scaffold(<br>        appBar: AppBar(title: Text(&quot;Login&quot;)),<br>        body: BlocConsumer&lt;LoginBloc, LoginState&gt;(<br>          listener: (context, state) {<br>            if (state is LoginSuccess) {<br>              ScaffoldMessenger.of(context).showSnackBar(<br>                SnackBar(content: Text(&#39;Login Successful!&#39;)),<br>              );<br>            } else if (state is LoginFailure) {<br>              ScaffoldMessenger.of(context).showSnackBar(<br>                SnackBar(content: Text(state.message)),<br>              );<br>            }<br>          },<br>          builder: (context, state) {<br>            return Padding(<br>              padding: const EdgeInsets.all(16.0),<br>              child: Column(<br>                children: [<br>                  TextField(controller: emailController, decoration: InputDecoration(labelText: &quot;Email&quot;)),<br>                  TextField(controller: passwordController, decoration: InputDecoration(labelText: &quot;Password&quot;), obscureText: true),<br>                  const SizedBox(height: 20),<br>                  ElevatedButton(<br>                    onPressed: () {<br>                      BlocProvider.of&lt;LoginBloc&gt;(context).add(<br>                        LoginButtonPressed(emailController.text, passwordController.text),<br>                      );<br>                    },<br>                    child: state is LoginLoading ? CircularProgressIndicator() : Text(&quot;Login&quot;),<br>                  ),<br>                ],<br>              ),<br>            );<br>          },<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><h3>🚀 main.dart</h3><pre>import&#39;package:flutter/material.dart&#39;;<br>import &#39;core/di/service_locator.dart&#39;;<br>import &#39;presentation/login/login_page.dart&#39;;</pre><pre>void main() {<br>  init(); // Initialize GetIt<br>  runApp(const MyApp());<br>}</pre><pre>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br>  <br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Clean Arch Login&#39;,<br>      home: LoginPage(),<br>    );<br>  }<br>}</pre><h3>📚 Conclusion</h3><p>This simple project shows the power of Clean Architecture in Flutter using BLoC, Provider, and GetIt. It’s highly maintainable and ready for scale. Once you’re familiar with this pattern, you can easily plug in Firebase, GraphQL, APIs, or databases.</p><h3>🛠 Source Code</h3><p>Check the full project here:<br>👉 <a href="https://github.com/oganaa2472/mgl_smart_service">GitHub — mgl_smart_service</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1df1ad166786" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic programming problems list for beginners]]></title>
            <link>https://medium.com/@marvelous_brass_marten_205/dynamic-programming-problems-list-for-beginners-a6f553bff9cc?source=rss-822939c20655------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6f553bff9cc</guid>
            <category><![CDATA[dynamic-programming]]></category>
            <dc:creator><![CDATA[Gana Oyundalai]]></dc:creator>
            <pubDate>Tue, 01 Jul 2025 19:46:59 GMT</pubDate>
            <atom:updated>2025-07-01T19:46:59.524Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first started learning dynamic programming (DP), I used to solve problems randomly from here and there. But this approach was not very effective. Later, I started categorizing problems, and I realized that there are actually different types of DP. This helped me a lot in learning how to classify problems. So, for beginners who are just starting out, I recommend this list of DP topics.</p><p>Here is a structured guide to master every major Dynamic Programming (DP) category, with 5 carefully selected LeetCode problems per section. These problems are handpicked to help you gradually build intuition and skill in each DP type.</p><h3>🧱 1. Linear DP (1D DP)</h3><p>This is the most basic form of DP. We define dp[i] as the optimal answer for the first i elements.</p><h3>🧪 Core Idea</h3><p>Build dp[i] using previous states like dp[i-1], dp[i-2], etc.</p><ol><li><a href="https://leetcode.com/problems/climbing-stairs/description/"><strong>Climbing</strong> <strong>Stairs</strong></a> — Ways to reach the nth step with 1 or 2 steps at a time.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/70-climbing-stairs/climbing-stairs.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/fibonacci-number/">Fibonacci Numbers</a> — Standard DP recurrence.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/1013-fibonacci-number/fibonacci-number.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/min-cost-climbing-stairs/"><strong>Min Cost Climbing Stairs</strong> </a>— Pay a cost to step; find the minimum total cost.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/747-min-cost-climbing-stairs/min-cost-climbing-stairs.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/house-robber/description/"><strong>House Robber</strong></a> — Max sum without robbing two adjacent houses.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/198-house-robber/house-robber.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/decode-ways/"><strong>Decode Ways</strong></a> — Count how many ways to decode a numeric string (like &#39;12&#39; → AB or L).<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/91-decode-ways/decode-ways.cpp">View on GitHub</a></li></ol><h3>🔲 2. 2-Dimensional DP (Table DP)</h3><p>Used when the state depends on two indices (e.g., ranges, substrings, etc.)</p><ol><li><a href="https://leetcode.com/problems/longest-common-subsequence/description/"><strong>Longest Common Subsequence</strong></a> <strong>(LCS)</strong> — Between two strings.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/1250-longest-common-subsequence/longest-common-subsequence.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/edit-distance/"><strong>Edit Distance</strong></a> — Minimum operations to convert one string into another.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/91-decode-ways/decode-ways.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/interleaving-string/"><strong>Interleaving Strings</strong></a> — Check if a string is formed by interleaving two others.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/97-interleaving-string">View on GitHub</a></li><li><a href="https://leetcode.com/problems/distinct-subsequences/"><strong>Distinct Subsequences</strong></a> — Count subsequences of one string that form another.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/115-distinct-subsequences">View on GitHub</a></li><li><a href="https://leetcode.com/problems/wildcard-matching/"><strong>Wildcard Matching</strong></a> — Pattern matching with and ?.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/44-wildcard-matching/wildcard-matching.cpp">View on GitHub</a></li></ol><h3>🧱 3. DP on Grid</h3><p>This is a special form of 2D DP, focused on moving in a grid (usually right and down).</p><ol><li><a href="https://leetcode.com/problems/unique-paths/description/"><strong>Unique Paths</strong></a> — Count number of paths from top-left to bottom-right.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/62-unique-paths">View on GitHub</a></li><li><a href="https://leetcode.com/problems/minimum-path-sum/"><strong>M</strong></a><strong>inimum Path Sum</strong> — Find path with the lowest cost.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/64-minimum-path-sum">View on GitHub</a></li><li><a href="https://leetcode.com/problems/coin-change-ii/"><strong>Coin Change on Grid</strong></a> — Paths with certain weights or restrictions.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/518-coin-change-ii">View on GitHub</a></li><li><a href="https://leetcode.com/problems/unique-paths-ii/description/"><strong>Grid with Obstacles</strong></a> — Same as Unique Paths but some blocks are disabled.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/63-unique-paths-ii">View on GitHub</a></li><li><a href="https://leetcode.com/problems/cherry-pickup/description/"><strong>Cherry Pickup</strong></a> — Advanced grid DP with two people collecting cherries.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/741-cherry-pickup">View on GitHub</a></li></ol><h3>🎒 4. Knapsack DP</h3><p>Used when we choose items under constraints (weight/volume/cost).</p><ol><li><a href="https://leetcode.com/problems/ones-and-zeroes/description/"><strong>Ones and Zeroes</strong></a> — Pick items with max value without exceeding weight.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/474-ones-and-zeroes">View on GitHub</a></li><li><a href="https://leetcode.com/problems/last-stone-weight-ii/"><strong>Last Stone Weight II</strong></a> — <a href="https://leetcode.com/problems/last-stone-weight-ii/">Can we make a given</a> sum using a subset?<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/1130-last-stone-weight-ii">View on GitHub</a></li><li><a href="https://leetcode.com/problems/partition-equal-subset-sum/description/"><strong>Partition Equal Subset Sum</strong></a> — Can we split an array into two equal-sum parts?<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/416-partition-equal-subset-sum">View on GitHub</a></li><li><a href="https://leetcode.com/problems/target-sum/description/"><strong>Target Sum</strong></a> — Assign + or — to reach a target.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/494-target-sum">View on GitHub</a></li><li><a href="https://leetcode.com/problems/profitable-schemes/description/"><strong>Profitable Schemes</strong></a> <a href="https://leetcode.com/problems/profitable-schemes/">— Count how many</a> subsets reach a given sum.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/911-profitable-schemes">View on GitHub</a></li></ol><h3>📈 5. Longest Increasing Subsequence (LIS)</h3><ol><li><a href="https://leetcode.com/problems/longest-increasing-subsequence/description/"><strong>LIS (O(n²) and O(n log n))</strong></a> — Find length of the longest increasing subsequence.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/300-longest-increasing-subsequence">View on GitHub</a></li><li><a href="https://leetcode.com/problems/longest-unequal-adjacent-groups-subsequence-ii/description/"><strong>Longest Unequal Adjacent Groups Subsequence II</strong></a> — LIS<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/2901.LongestUnequalAdjacentGroupsSubsequence-II.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/longest-unequal-adjacent-groups-subsequence-ii/"><strong>Number of LIS</strong> </a>— Count all increasing subsequences of maximum length.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/494-target-sum">View on GitHub</a></li><li><a href="https://leetcode.com/problems/largest-divisible-subset/"><strong>Largest Divisible Subset</strong></a> — LIS.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/368-largest-divisible-subset">View on GitHub</a></li><li><a href="https://leetcode.com/problems/largest-divisible-subset/"><strong>Russian Doll</strong></a> <a href="https://leetcode.com/problems/russian-doll-envelopes/description/"><strong>Envelopes</strong></a> — 2D LIS variation.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/354-russian-doll-envelopes">View on GitHub</a></li></ol><h3>✍️ 6. Longest Common Subsequence (LCS)</h3><ol><li><strong>LCS (Basic)</strong> — Longest common subsequence of two strings.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/1250-longest-common-subsequence/longest-common-subsequence.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/shortest-common-supersequence/description/"><strong>Shortest Common Supersequence</strong></a> — Shortest string that has both strings as subsequences.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/1170-shortest-common-supersequence/shortest-common-supersequence.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/delete-operation-for-two-strings/description/"><strong>Minimum Insertion/Deletion to Make Equal</strong></a> — Using LCS length.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/583-delete-operation-for-two-strings">View on GitHub</a></li><li><a href="https://www.geeksforgeeks.org/problems/print-all-lcs-sequences3413/1"><strong>Print the LCS</strong></a> — Reconstruct the LCS, not just length.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/print-all-lcs-sequences.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/longest-palindromic-subsequence/description/"><strong>Longest Palindromic Subsequence</strong></a> — LCS of s and reverse(s).<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/516-longest-palindromic-subsequence">View on GitHub</a></li></ol><h3>🔤 7. DP on String</h3><ol><li><a href="https://leetcode.com/problems/palindrome-partitioning-ii/"><strong>Palindrome Partitioning II</strong></a> — Minimum cuts for palindrome substrings.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/132-palindrome-partitioning-ii/palindrome-partitioning-ii.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/regular-expression-matching/"><strong>Regular Expression Matching</strong></a> — Pattern matching with . and .<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/10-regular-expression-matching">View on GitHub</a></li><li><a href="https://leetcode.com/problems/scramble-string/"><strong>Scramble String</strong></a> — Recursive check using DP and memoization.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/87-scramble-string">View on GitHub</a></li><li><a href="https://leetcode.com/problems/word-break/"><strong>Word Break</strong></a> — Check if a string can be split into valid dictionary words.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/139-word-break">View on GitHub</a></li><li><a href="https://leetcode.com/problems/longest-palindromic-subsequence/description/"><strong>Longest Palindromic Subsequence</strong></a> — Find the longest substring that is a palindrome.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/516-longest-palindromic-subsequence">View on GitHub</a></li></ol><h3>➕ 8. Cumulative Sum (Prefix Sum + DP)</h3><ol><li><a href="https://leetcode.com/problems/range-sum-query-immutable/"><strong>Range Sum Query</strong></a> — Fast sum queries in a range, Segment Tree.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/303-range-sum-query-immutable">View on GitHub</a></li><li><a href="https://leetcode.com/problems/range-sum-query-2d-immutable/description/"><strong>Range Sum Query 2D — Immutable</strong></a> <a href="https://leetcode.com/problems/range-sum-query-2d-immutable/">— DP with prefix sums, Segment Tree.</a><strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/307-range-sum-query-mutable">View on GitHub</a></li><li><a href="https://leetcode.com/problems/range-sum-query-2d-immutable/"><strong>Cou</strong></a><a href="https://leetcode.com/problems/subarray-sum-equals-k/"><strong>nt Subarrays with Sum K</strong></a> — Using prefix sums and hashing.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/560-subarray-sum-equals-k">View on GitHub</a></li><li><a href="https://leetcode.com/problems/count-square-submatrices-with-all-ones/"><strong>Count Square Submatrices with All Ones</strong></a> — <a href="https://leetcode.com/problems/count-square-submatrices-with-all-ones/">Prefix row sums + DP.</a><strong>Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/1402-count-square-submatrices-with-all-ones">View on GitHub</a></li><li><a href="https://leetcode.com/problems/count-square-submatrices-with-all-ones/"><strong>Maximal</strong></a> <a href="https://leetcode.com/problems/maximal-square/description/"><strong>Square</strong></a> — DP.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/221-maximal-square">View on GitHub</a></li></ol><h3>🧮 9. Matrix Chain Multiplication (Interval DP)</h3><ol><li><a href="https://practice.geeksforgeeks.org/problems/matrix-chain-multiplication0303/1"><strong>Matrix Chain Multiplication</strong></a> — Parenthesize matrix multiplications to minimize cost.</li><li><a href="https://leetcode.com/problems/burst-balloons/description/"><strong>Burst Balloons</strong></a> — Choose order to burst balloons to maximize coins.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/312-burst-balloons">View on GitHub</a></li><li><a href="https://leetcode.com/problems/minimum-cost-to-cut-a-stick/"><strong>Minimize Cost to Cut a Stick</strong></a> — Optimal way to cut a stick into parts.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/1547.Minimum-Cost-Cut-Stick.cpp">View on GitHub</a></li><li><a href="https://leetcode.com/problems/palindrome-partitioning-ii/"><strong>Palindrome Partitioning</strong></a> — Min cuts to make all substrings palindromes.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/132-palindrome-partitioning-ii">View on GitHub</a></li><li><a href="https://leetcode.com/problems/predict-the-winner/"><strong>Predict the Winner</strong></a> — We can decide who is win.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/blob/main/486-predict-the-winner/predict-the-winner.cpp">View on GitHub</a></li></ol><h3>⚡ 10. Kadane’s Algorithm (Subarray Optimization)</h3><ol><li><a href="https://leetcode.com/problems/maximum-subarray/"><strong>Maximum Subarray</strong></a> <strong>(Kadane)</strong> — Classic problem (LeetCode #53).<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/53-maximum-subarray">View on GitHub</a></li><li><a href="https://leetcode.com/problems/maximum-product-subarray/description/"><strong>Maximum Product Subarray</strong></a> — Keep track of min and max.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/152-maximum-product-subarray">View on GitHub</a></li><li><a href="https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/"><strong>Length of Longest Fibonacci Subsequence</strong></a> — Keep track of max length of Fibo sequence<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/905-length-of-longest-fibonacci-subsequence">View on GitHub</a></li><li><a href="https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/"><strong>Best</strong></a> <a href="https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/"><strong>Time to Buy and Sell Stock</strong></a> — DP with max profit difference.<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/121-best-time-to-buy-and-sell-stock">View on GitHub</a></li><li><a href="https://leetcode.com/problems/maximum-sum-circular-subarray/description/"><strong>Maximum Sum Circular Subarray</strong></a> — Use Kadane twice (normal and inverted).<strong>My Solution:</strong> <a href="https://github.com/oganaa2472/Leetcode/tree/main/954-maximum-sum-circular-subarray">View on GitHub</a></li></ol><p>Here is more detail about DP link <a href="https://oganaa.hashnode.dev/dynamic-programming-essentials-understanding-key-concepts-and-exploring-dp-variants">click here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6f553bff9cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>