w3resource

Daily Coding Challenges & Projects


Monday


Frontend Challenge

JavaScript Logical Puzzle

Challenge: Write a function to flatten a nested array without using recursion.

Example:

		
		
console.log(flatten([1, [2, [3, 4], 5], 6]));
// Output: [1, 2, 3, 4, 5, 6]

Hint: Use a loop and a stack (or a queue) to process elements.

Backend Challenge

Problem: Reverse a linked list in C/C++/C#.

  • Implement a function that takes a linked list and returns it reversed.
  • Optimize for both iterative and recursive solutions.

Database Query Challenge

Problem:Write a SQL query to find all employees who joined in the last 3 months.

Hint: Use DATE_ADD() or INTERVAL in your query.

Sample table: employees
+-------------+-------------+-------------+----------+--------------------+------------+------------+----------+----------------+------------+---------------+
| EMPLOYEE_ID | FIRST_NAME  | LAST_NAME   | EMAIL    | PHONE_NUMBER       | HIRE_DATE  | JOB_ID     | SALARY   | COMMISSION_PCT | MANAGER_ID | DEPARTMENT_ID |
+-------------+-------------+-------------+----------+--------------------+------------+------------+----------+----------------+------------+---------------+
|         100 | Steven      | King        | SKING    | 515.123.4567       | 2003-06-17 | AD_PRES    | 24000.00 |           0.00 |          0 |            90 |
|         101 | Neena       | Kochhar     | NKOCHHAR | 515.123.4568       | 2005-09-21 | AD_VP      | 17000.00 |           0.00 |        100 |            90 |
|         102 | Lex         | De Haan     | LDEHAAN  | 515.123.4569       | 2001-01-13 | AD_VP      | 17000.00 |           0.00 |        100 |            90 |
|         103 | Alexander   | Hunold      | AHUNOLD  | 590.423.4567       | 2006-01-03 | IT_PROG    |  9000.00 |           0.00 |        102 |            60 |
|         104 | Bruce       | Ernst       | BERNST   | 590.423.4568       | 2007-05-21 | IT_PROG    |  6000.00 |           0.00 |        103 |            60 |
|         105 | David       | Austin      | DAUSTIN  | 590.423.4569       | 2005-06-25 | IT_PROG    |  4800.00 |           0.00 |        103 |            60 |
|         106 | Valli       | Pataballa   | VPATABAL | 590.423.4560       | 2006-02-05 | IT_PROG    |  4800.00 |           0.00 |        103 |            60 |
|         107 | Diana       | Lorentz     | DLORENTZ | 590.423.5567       | 2007-02-07 | IT_PROG    |  4200.00 |           0.00 |        103 |            60 |
|         108 | Nancy       | Greenberg   | NGREENBE | 515.124.4569       | 2002-08-17 | FI_MGR     | 12008.00 |           0.00 |        101 |           100 |
|         109 | Daniel      | Faviet      | DFAVIET  | 515.124.4169       | 2002-08-16 | FI_ACCOUNT |  9000.00 |           0.00 |        108 |           100 |
.......

View the table



Data Structures & Algorithms Challenge

  • Easy: Find the first non-repeating character in a string.
    • Hint: Use a hash map to store character counts.
  • Medium: Implement binary search on a rotated sorted array.
    • Hint: Modify standard binary search logic to handle rotation.
  • Hard: Find the longest palindromic substring in a given string.
    • Hint: Expand around center or use dynamic programming.

Bug of the Day

C Bug:


#include 

int main() {
    int arr[3] = {1, 2, 3};
    for (int i = 0; i <= 3; i++) {
        printf("%d ", arr[i]);
    }
    return 0;
}

Hint: The loop index is out of bounds!

Find and fix the issue!

  • C++ Bug:
    
    #include 
    
    void printMessage(std::string msg) {
        if (msg.empty()) {
            std::cout << "Message is empty" << std::endl;
        }
        delete &msg;  // Buggy line
        std::cout << msg << std::endl;
    }
    
    int main() {
        printMessage("Hello, World!");
        return 0;
    }
    		
    
  • C# Bug:
    			
    using System;
    
    class Program {
        static void Main() {
            int[] numbers = new int[3] {1, 2, 3};
            foreach (int i in numbers) {
                if (i == 2) {
                    numbers[i] = 10;  // Modifying collection inside foreach
                }
                Console.WriteLine(i);
            }
        }
    }
    
     
  • 📋 Daily Micro-Project

    Frontend Challenge:

      Mini Project: Build a Pure CSS Animated Progress Bar that fills up dynamically.

    • Difficult Level: Moderate
    • Tech Stack: HTML, CSS (No JavaScript)
    • Bonus: Make the progress bar responsive and add a smooth gradient animation.

    Trivia: 5 Fun Facts

    • Who created Linux?
      • Answer: Linus Torvalds.
    • When was JavaScript first released?
      • Answer: 1995.
    • Which company developed React?
      • Answer: Facebook.
    • Which language is used in TensorFlow for backend computations?
      • Answer: C++.
    • What was the first programming language?
      • Answer: FORTRAN, released in 1957.

    Tool of the Day

    ESLint

    ESLint is a popular JavaScript and TypeScript linter that helps developers find and fix problems in their code. It enforces coding standards, detects errors, and improves code quality by catching issues like unused variables, inconsistent formatting, and potential bugs. ESLint is highly configurable, allowing teams to define custom rules or extend existing rule sets, such as Airbnb, Prettier, or StandardJS. It integrates seamlessly with modern development tools and CI/CD pipelines to maintain code consistency.

    Learn more:ESLint

    Interview Question of the Day

    Daily Interview Questions

      Frontend (4 Questions)
      • What is the difference between == and === in JavaScript?
      • Explain the concept of closures in JavaScript with an example.
      • How does CSS Grid differ from Flexbox, and when should each be used?
      • What are props and state in React, and how do they differ?
      Backend (4 Questions)
      • What is the difference between monolithic and microservices architecture?
      • Explain how garbage collection works in Java.
      • How does event-driven programming work in Node.js?
      • What are the differences between POST and PUT HTTP methods?
      Database (3 Questions)
      • What is normalization in SQL, and why is it important?
      • Explain the differences between ACID and BASE properties in databases.
      • What is sharding, and how does it improve database performance?
      Others (2 Questions)
      • What are the key differences between a virtual machine and a container?
      • Explain the role of a scheduler in an operating system.

    Daily Quiz Challenge

    Frontend Quiz (3 Questions)

    1. Which of the following best describes the difference between null and undefined in JavaScript?
      1. null is an assigned value, while undefined means a variable hasn't been assigned a value.
      2. Both mean the same thing.
      3. undefined is a keyword, while null is not.
      4. null is only used in arrays.
    1. Which scenario is a good use case for event delegation in JavaScript?
      1. Applying styles dynamically to elements.
      2. Handling events efficiently for dynamically added elements.
      3. Preventing event bubbling.
      4. Making AJAX requests faster.
    1. How does the Virtual DOM in React improve performance?
      1. It removes the need for state management.
      2. It updates only changed parts of the real DOM instead of re-rendering everything.
      3. It eliminates JavaScript execution in the browser.
      4. It converts React components into plain HTML before rendering.

    Backend Quiz (3 Questions)

    1. What is the primary difference between synchronous and asynchronous programming in Node.js?
      1. Synchronous code runs line by line and blocks execution, while asynchronous code does not.
      2. Asynchronous programming is only possible with async/await.
      3. Synchronous functions execute in the background.
      4. Asynchronous functions execute only inside promises.
    1. Which of the following best describes the difference between a thread and a process?
      1. A process can contain multiple threads, while a thread is the smallest unit of execution.
      2. Threads require more memory than processes.
      3. A thread runs independently, while a process shares resources with other processes.
      4. Threads always execute on separate cores.
    1. How does Python handle memory management?
      1. It uses manual garbage collection.
      2. It relies on the Global Interpreter Lock (GIL) for memory allocation.
      3. It has automatic garbage collection and reference counting.
      4. It uses pointers like C++.

    Database Quiz (2 Questions)

    1. What is the main difference between INNER JOIN and LEFT JOIN in SQL?
      1. LEFT JOIN returns all rows from the left table, while INNER JOIN returns only matching rows.
      2. INNER JOIN retrieves all records, while LEFT JOIN filters duplicates.
      3. LEFT JOIN only works with primary keys.
      4. INNER JOIN is used only with indexed columns.
    1. How does indexing improve query performance in databases?
      1. It reduces database size.
      2. It allows faster searching by storing a sorted reference of the data.
      3. It prevents duplicate rows.
      4. It eliminates the need for foreign keys.

    Weekly Cross-Domain Activities

    Task: Hints for Building a Simple Weather App using OpenWeatherMap API

    1. Get an API Key
      • Sign up at OpenWeatherMap and get a free API key.
    1. Choose an HTTP Request Method
      • Use fetch() in JavaScript or requests in Python to get weather data.
    1. API Endpoint Example
    1. Use this URL:
      • https://api.openweathermap.org/data/2.5/weather?q=London&appid=YOUR_API_KEY&units=metric
      • Replace London with the city name and YOUR_API_KEY with your actual API key
    1. Extract Important Data
      • Parse the JSON response to extract key details like temperature, humidity, and weather description.
    1. Display the Data
      • Show weather details in a simple UI using HTML, CSS, and JavaScript.
      • Example: Display city name, temperature, and weather conditions.
    1. Handle Errors Gracefully
      • Show an error message if the city is not found or the API call fails.
    1. Enhancements (Optional)
      • Allow users to enter any city name.
      • Show weather icons based on conditions.
      • Use geolocation to fetch the user’s current weather.

    orgopenweathermap.org

    Current weather and forecast - OpenWeatherMap

    OpenWeather provides comprehensive weather data services, including current, forecast, and historical weather information. Explore a wide range of APIs for solar radiation, road risk assessment, solar energy prediction, and more, with global coverage and user-friendly access. Ideal for developers and businesses seeking accurate and reliable weather insights.

    Real-World Project of the Week

    Project: Build a Personal Portfolio Website

    Tech Stack: HTML, CSS, JavaScript (Optional: React, TailwindCSS)


    Previous Daily Coding Challenges & Projects : 04-04-2025

    

    Follow us on Facebook and Twitter for latest update.