Skip to main content

Posts

Showing posts from November, 2024

Free database for beginners for prototype online

For free online databases suitable for beginners in India, here are some reliable options that support SQL and work well for prototyping: Firebase Realtime Database / Firestore Firebase offers a limited free tier and is easy to set up for quick prototypes. It provides both SQL-like Firestore and NoSQL Realtime Database options. The free plan includes 1GB storage and basic analytics. Firebase Console Supabase Supabase is an open-source alternative to Firebase with a PostgreSQL backend, making it a solid choice for SQL beginners. The free tier provides up to 500MB of database space, unlimited API requests, and real-time capabilities. Supabase PlanetScale Based on MySQL, PlanetScale is great for beginners and offers a free plan with 5GB storage and a user-friendly interface. It’s especially suitable for scalable prototypes and integrates well with modern frameworks. PlanetScale ElephantSQL ElephantSQL offers a free tier for PostgreSQL databases with 20MB storage. It’s easy to use and prov

Move zeros to End

 Index Problem is we need to move all the zeros to the right and non-zeros to the left. Move Zeros to End Approaches we can follow are: 1st Approch :  1. Your approach of swapping each 0 element with the end ( j pointer) could work, but it requires some adjustments to handle the indices correctly. However, it’s less efficient than moving the non-zero elements to the front as it repeatedly swaps each 0 with elements toward the end, making it potentially  O ( n 2 ) O(n^2) O ( n 2 ) in the worst case due to unnecessary swaps. Here's a refined version of your approach to help clarify the issues and make it function correctly: Adjusted Code Using End-Pointer Swapping Initialize j to nums.size() - 1 (the last index). Traverse from the beginning, and for each 0 , swap it with nums[j] , then decrement j . However, keep in mind that this will cause the relative order of non-zero elements to change. class Solution { public:     void moveZeroes(vector<int>& nums) {         int