question_slug stringlengths 3 77 | title stringlengths 1 183 | slug stringlengths 12 45 | summary stringlengths 1 160 ⌀ | author stringlengths 2 30 | certification stringclasses 2
values | created_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | updated_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | hit_count int64 0 10.6M | has_video bool 2
classes | content stringlengths 4 576k | upvotes int64 0 11.5k | downvotes int64 0 358 | tags stringlengths 2 193 | comments int64 0 2.56k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
group-sold-products-by-the-date | 2 Simple SQL Solutions: Group_Concat() and String_Agg() | 2-simple-sql-solutions-group_concat-and-vvn8i | \nSELECT \n sell_date,\n COUNT(product) AS num_sold,\n STRING_AGG(product, \',\') WITHIN GROUP (ORDER BY product ASC) AS products\nFROM (SELECT DISTINCT * FR | mirandanathan | NORMAL | 2021-02-20T19:11:14.699971+00:00 | 2021-02-20T19:11:35.272613+00:00 | 1,814 | false | ```\nSELECT \n sell_date,\n COUNT(product) AS num_sold,\n STRING_AGG(product, \',\') WITHIN GROUP (ORDER BY product ASC) AS products\nFROM (SELECT DISTINCT * FROM Activities) T\nGROUP BY sell_date\nORDER BY 1 ASC\n```\n\n```\nSELECT \n sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINC... | 15 | 2 | [] | 3 |
group-sold-products-by-the-date | STRING_AGG + Explanation | string_agg-explanation-by-alirezah-ubkq | This query will show the disired result: \n select sell_date, count(distinct(product)) as num_sold,\n STRING_AGG(product,\',\') within group (order by product) | Alirezah | NORMAL | 2022-07-10T18:37:20.095072+00:00 | 2022-07-10T18:40:40.334501+00:00 | 2,341 | false | This query will show the disired result: \n select sell_date, count(distinct(product)) as num_sold,\n STRING_AGG(product,\',\') within group (order by product) as products\nfrom\n(SELECT DISTINCT sell_date, product FROM Activities) T\ngroup by sell_date\norder by sell_date\n\nthe reason for using this part ((SELECT DIS... | 13 | 0 | ['MS SQL Server'] | 1 |
group-sold-products-by-the-date | Grouping With Aggregations 🏆 | grouping-with-aggregations-by-hridoy100-mhxc | My SQL\n\nFirst, we group the data by the sell_date column. This allows us to count the number of unique products sold on each sell date, which we store in the | hridoy100 | NORMAL | 2023-08-11T20:46:55.380098+00:00 | 2023-08-11T20:46:55.380124+00:00 | 1,533 | false | # My SQL\n\nFirst, we group the data by the `sell_date` column. This allows us to count the number of unique products sold on each sell date, which we store in the `num_sold` column.\n\nThe most challenging part is to sort and join all unique product names in each group to get the products column. We can use the `GROUP... | 12 | 0 | ['Python', 'Python3', 'MySQL', 'Pandas'] | 0 |
group-sold-products-by-the-date | MySQL Easy Solution. | mysql-easy-solution-by-dilmurat-aliev-8k1t | Code\n\nSELECT \n sell_date, \n COUNT(DISTINCT(product)) AS num_sold, \n GROUP_CONCAT(DISTINCT(product)) AS products\nFROM Activities\nGROUP BY sell_date\n\n | dilmurat-aliev | NORMAL | 2023-07-07T11:00:13.327378+00:00 | 2023-07-07T11:01:36.748721+00:00 | 1,014 | false | # Code\n```\nSELECT \n sell_date, \n COUNT(DISTINCT(product)) AS num_sold, \n GROUP_CONCAT(DISTINCT(product)) AS products\nFROM Activities\nGROUP BY sell_date\n```\n\n | 12 | 0 | ['MySQL'] | 1 |
group-sold-products-by-the-date | MS SQL SERVER Simple Solution | ms-sql-server-simple-solution-by-nazir_c-72kh | \nselect sell_date, \n COUNT(product) as num_sold,\n STRING_AGG(product,\',\') WITHIN GROUP (ORDER BY product) as products from\n (select distinct sell | nazir_cinu | NORMAL | 2020-07-24T04:02:37.671223+00:00 | 2020-07-24T04:02:37.671260+00:00 | 3,115 | false | ```\nselect sell_date, \n COUNT(product) as num_sold,\n STRING_AGG(product,\',\') WITHIN GROUP (ORDER BY product) as products from\n (select distinct sell_date,product FROM Activities) Act\n GROUP BY sell_date\n``` | 11 | 1 | [] | 3 |
group-sold-products-by-the-date | Easy Solution | easy-solution-by-jahanviraycha-bgxn | SQL\n\nselect sell_date, count(distinct product) as num_sold,group_concat(distinct product) as products from Activities group by sell_date\n\n# Python\n\nimport | jahanviraycha | NORMAL | 2023-08-13T11:55:58.158026+00:00 | 2023-08-13T11:55:58.158052+00:00 | 1,960 | false | # SQL\n```\nselect sell_date, count(distinct product) as num_sold,group_concat(distinct product) as products from Activities group by sell_date\n```\n# Python\n```\nimport pandas as pd\n\ndef categorize_products(activities: pd.DataFrame) -> pd.DataFrame:\n return activities.groupby(\'sell_date\')[\'product\'].agg([(\'... | 10 | 0 | ['Pandas'] | 0 |
group-sold-products-by-the-date | MS SQL / Using STRING_AGG | ms-sql-using-string_agg-by-lilybone-5uwb | \nwith t as (\n select distinct * from Activities)\n\nselect \n sell_date\n ,count(1) as num_sold\n ,string_agg(product,\',\') within group (order | LilyBone | NORMAL | 2022-05-01T06:17:33.003223+00:00 | 2022-05-01T06:17:33.003263+00:00 | 1,769 | false | ```\nwith t as (\n select distinct * from Activities)\n\nselect \n sell_date\n ,count(1) as num_sold\n ,string_agg(product,\',\') within group (order by product) as products\nfrom t\ngroup by sell_date\norder by sell_date\n``` | 10 | 0 | ['MS SQL Server'] | 2 |
group-sold-products-by-the-date | Easy to understand Pandas solution | easy-to-understand-pandas-solution-by-hi-1fow | IntuitionI thought of how to use multiple aggregation function and save the values in different columns. I also needed to alphabetically sort the products as re | Himanshu_soni2023 | NORMAL | 2025-01-12T18:31:53.106437+00:00 | 2025-01-12T18:31:53.106437+00:00 | 942 | false | # Intuition
I thought of how to use multiple aggregation function and save the values in different columns. I also needed to alphabetically sort the products as required in the test cases. Meaning: the product starting with an alphabet which comes before any other should be the first.
# Approach
1. Group the dataframe... | 9 | 0 | ['Pandas'] | 0 |
group-sold-products-by-the-date | ✅ ✅ Best Solution Using Group By , Group_concat | best-solution-using-group-by-group_conca-3rem | Please Upvote if you Like it\n##### The GROUP BY statement groups rows that have the same values into summary rows.\n##### The GROUP BY statement is often used | vikramsinghgurjar | NORMAL | 2022-07-16T21:00:16.002290+00:00 | 2022-07-17T07:02:21.055963+00:00 | 1,322 | false | #### **Please Upvote if you Like it**\n##### The GROUP BY statement groups rows that have the same values into summary rows.\n##### The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.\n##### Another group method we use is *... | 9 | 0 | [] | 0 |
group-sold-products-by-the-date | Simple and Easy Solution using group_concat | simple-and-easy-solution-using-group_con-0etk | \nSELECT \n sell_date,\n count(DISTINCT(product)) as num_sold,\n GROUP_CONCAT( DISTINCT product) as products\nfrom Activities \nGroup by sell_date;\n\n | pruthashouche | NORMAL | 2022-07-06T07:35:05.814784+00:00 | 2022-07-06T07:35:05.814823+00:00 | 706 | false | ```\nSELECT \n sell_date,\n count(DISTINCT(product)) as num_sold,\n GROUP_CONCAT( DISTINCT product) as products\nfrom Activities \nGroup by sell_date;\n```\n\n**Please UpVote if it was Helpful :)** | 8 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | SQL simple Query | sql-simple-query-by-deepakumar-developer-p7dz | \n# Code\n\nwith ProductCounts as (\n SELECT\n sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINCT product ORDER BY product) AS | deepakumar-developer | NORMAL | 2023-12-25T12:47:20.939859+00:00 | 2023-12-25T12:47:20.939891+00:00 | 946 | false | \n# Code\n```\nwith ProductCounts as (\n SELECT\n sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINCT product ORDER BY product) AS products\n FROM Activities\n GROUP BY sell_date\n)\nSELECT sell_date, num_sold, products\nFROM ProductCounts \nORDER BY sell_date;\n``` | 7 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | GROUP_CONCAT() explanation ✅ || MySQL✅ || Pandas || Beats 100% !! | group_concat-explanation-mysql-pandas-be-zko3 | Intuition\n Describe your first thoughts on how to solve this problem. \n- In order to agrregate the product into a single row grouped by sell_date, we use GROU | prathams29 | NORMAL | 2023-06-17T09:38:41.876407+00:00 | 2023-08-01T10:19:40.323922+00:00 | 747 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- In order to agrregate the product into a single row grouped by sell_date, we use **GROUP_CONCAT()** function.\n- We can also specify the sorting condition in GROUP_CONCAT() as \n`GROUP_CONCAT(DISTINCT product ORDER BY product) as produc... | 7 | 0 | ['MySQL', 'Pandas'] | 0 |
group-sold-products-by-the-date | SQL Solution using GROUP_CONCAT() | Definition and Syntax of GROUP_CONCAT() | sql-solution-using-group_concat-definiti-sp72 | --GROUP_CONCAT() function in MySQL is used to concatenate data from multiple rows into one field\n--Syntax: SELECT col1, col2, ..., colN\n GROUP_CONCAT ( | prag-sri | NORMAL | 2022-09-18T08:36:21.543578+00:00 | 2022-09-18T08:36:21.543617+00:00 | 1,327 | false | --GROUP_CONCAT() function in MySQL is used to concatenate data from multiple rows into one field\n--Syntax: SELECT col1, col2, ..., colN\n GROUP_CONCAT ( [DISTINCT] col_name1 \n [ORDER BY clause] [SEPARATOR str_val] ) \n FROM table_name GROUP BY col_name2;\n\n SELECT sell_date,\n ... | 7 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | 1484. Group Sold Products By The Date | 1484-group-sold-products-by-the-date-by-ydkjk | ```\nSELECT sell_date, COUNT(DISTINCT(product)) as num_sold, \nGroup_Concat(distinct(product)\nORDER BY product) AS products\nFROM Activities \nGROUP BY sell_da | Spaulding_ | NORMAL | 2022-09-07T21:11:43.435018+00:00 | 2022-09-07T21:11:43.435054+00:00 | 986 | false | ```\nSELECT sell_date, COUNT(DISTINCT(product)) as num_sold, \nGroup_Concat(distinct(product)\nORDER BY product) AS products\nFROM Activities \nGROUP BY sell_date ORDER BY sell_date; | 7 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | SQL server easy solution | sql-server-easy-solution-by-karan-128-dhtt | Key points - \n1. Remove duplicates from the table using CTE\n2. Group by sell_date, count each sell date\n3. Use string_agg function and order within group by | karan-128 | NORMAL | 2022-08-29T19:29:44.793557+00:00 | 2022-08-29T19:29:44.793602+00:00 | 1,621 | false | **Key points - **\n1. Remove duplicates from the table using CTE\n2. Group by sell_date, count each sell date\n3. Use string_agg function and order within group by product.\n\n```\nwith cteactivity AS \n (SELECT DISTINCT *\n FROM activities)\nSELECT sell_date,\n\t\t count(product) AS num_sold,\n\t\t string_agg(pr... | 7 | 0 | ['MS SQL Server'] | 0 |
group-sold-products-by-the-date | Oracle SQL Solution and Explanation. | oracle-sql-solution-and-explanation-by-r-gqsr | Solution & explanation -\nThe below code is not working but as per the oracle it should work.\nClick this link to check on oracle website.\n\n\n/* Write your PL | ruthvikc27-dev | NORMAL | 2022-07-06T13:25:43.359458+00:00 | 2022-07-06T19:12:25.273826+00:00 | 1,300 | false | # Solution & explanation -\nThe below code is not working but as per the oracle it should work.\nClick this [link](https://livesql.oracle.com/apex/livesql/file/content_HT1O85E4BHSBWN93G1B3M8SI2.html) to check on oracle website.\n\n```\n/* Write your PL/SQL query statement below */\n\nSELECT TO_CHAR(sell_date, \'YYYY-MM... | 7 | 0 | ['Oracle'] | 0 |
group-sold-products-by-the-date | Superb Logic MYSQL | superb-logic-mysql-by-ganjinaveen-37tu | \n# Logic is to use distinct and group_concat\n\nselect sell_date,\ncount(distinct product) as num_sold,\nGroup_concat(distinct product) as products from activi | GANJINAVEEN | NORMAL | 2023-04-17T12:02:27.404236+00:00 | 2023-04-17T12:02:27.404280+00:00 | 1,493 | false | \n# Logic is to use distinct and group_concat\n```\nselect sell_date,\ncount(distinct product) as num_sold,\nGroup_concat(distinct product) as products from activities\ngroup by sell_date;\n\n```\n# please upvote me it would encourage me alot\n | 6 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | Group concat | group-concat-by-florentina-wb43 | Code\n\n# Write your MySQL query statement below\nSELECT sell_date, COUNT(DISTINCT product) as num_sold, GROUP_CONCAT(\n DISTINCT product \n ORDER BY prod | florentina | NORMAL | 2023-02-05T09:53:44.945209+00:00 | 2023-02-05T09:53:44.945251+00:00 | 720 | false | # Code\n```\n# Write your MySQL query statement below\nSELECT sell_date, COUNT(DISTINCT product) as num_sold, GROUP_CONCAT(\n DISTINCT product \n ORDER BY product ASC \n separator \',\') AS Products\nFROM Activities\nGROUP BY sell_date\nORDER BY sell_date;\n``` | 6 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | MySQL Easy Solution | mysql-easy-solution-by-roshanshetty2816-yqxz | \n# Write your MySQL query statement below\nSELECT sell_date,COUNT(DISTINCT(product)) AS num_sold,\nGROUP_CONCAT(DISTINCT product SEPARATOR "," ) AS products FR | roshanshetty2816 | NORMAL | 2022-09-03T08:20:59.768870+00:00 | 2022-09-03T08:20:59.768912+00:00 | 849 | false | ```\n# Write your MySQL query statement below\nSELECT sell_date,COUNT(DISTINCT(product)) AS num_sold,\nGROUP_CONCAT(DISTINCT product SEPARATOR "," ) AS products FROM Activities\nGroup by sell_date\nORDER BY sell_date;\n```\n# upvote if u find it useful | 6 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | sql very easy solution | sql-very-easy-solution-by-pratham_18-ccd8 | \nselect sell_date,\ncount(distinct(product)) num_sold,\ngroup_concat(distinct(product)) products\nfrom Activities\ngroup by sell_date\norder by sell_date; | Pratham_18 | NORMAL | 2022-05-28T08:20:05.355291+00:00 | 2022-05-28T08:20:05.355336+00:00 | 962 | false | ```\nselect sell_date,\ncount(distinct(product)) num_sold,\ngroup_concat(distinct(product)) products\nfrom Activities\ngroup by sell_date\norder by sell_date;``` | 6 | 0 | ['MySQL'] | 1 |
group-sold-products-by-the-date | simple solution | simple-solution-by-maboeths666-93f7 | SELECT sell_date, count(DISTINCT product) as num_sold, group_concat(DISTINCT product separator \',\') as products\nFROM Activities\nGROUP BY sell_date\nORDER BY | maboeths666 | NORMAL | 2022-01-21T22:33:55.665846+00:00 | 2022-01-21T22:33:55.665890+00:00 | 704 | false | SELECT sell_date, count(DISTINCT product) as num_sold, group_concat(DISTINCT product separator \',\') as products\nFROM Activities\nGROUP BY sell_date\nORDER BY sell_date | 6 | 0 | [] | 0 |
group-sold-products-by-the-date | Easy MySQL Solution | easy-mysql-solution-by-saranpadmakar-8did | \nselect sell_date, count(distinct product) as num_sold , \ngroup_concat(distinct product order by product asc separator \',\') as products \nfrom | saranpadmakar | NORMAL | 2020-06-17T22:54:01.674313+00:00 | 2020-06-21T21:24:59.908761+00:00 | 2,810 | false | ```\nselect sell_date, count(distinct product) as num_sold , \ngroup_concat(distinct product order by product asc separator \',\') as products \nfrom activities \ngroup by sell_date\norder by sell_date\n``` | 6 | 0 | [] | 1 |
group-sold-products-by-the-date | ✅EASY MYSQL SOLUTION | easy-mysql-solution-by-swayam28-396n | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | swayam28 | NORMAL | 2024-08-23T08:55:35.070286+00:00 | 2024-08-23T08:55:35.070328+00:00 | 798 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 5 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | MySQL Simple Clean Solution | mysql-simple-clean-solution-by-shree_gov-p7ii | Code\n\n# Write your MySQL query statement below\nSELECT sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINCT product) AS products\nF | Shree_Govind_Jee | NORMAL | 2024-04-02T03:52:53.783866+00:00 | 2024-04-02T03:52:53.783908+00:00 | 839 | false | # Code\n```\n# Write your MySQL query statement below\nSELECT sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINCT product) AS products\nFROM Activities\nGROUP BY sell_date\nORDER BY sell_date\n``` | 5 | 0 | ['Database', 'MySQL'] | 2 |
group-sold-products-by-the-date | SQL simple query | sql-simple-query-by-deepakumar-developer-vy21 | \n\n# Code\n\nSELECT\n sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINCT product ORDER BY product) AS products\nFROM Activities\nGROU | deepakumar-developer | NORMAL | 2023-12-25T13:00:26.479252+00:00 | 2023-12-25T13:00:26.479281+00:00 | 901 | false | \n\n# Code\n```\nSELECT\n sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINCT product ORDER BY product) AS products\nFROM Activities\nGROUP BY sell_date\nORDER BY sell_date;\n\n``` | 5 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | Group Sold Products By The Date | MySQL | group-sold-products-by-the-date-mysql-by-aykx | Intuition\n Describe your first thoughts on how to solve this problem. \nWe need to find the name and the number of different products sold on each date.\n\n# A | samabdullaev | NORMAL | 2023-10-25T21:46:19.563977+00:00 | 2023-10-25T21:46:19.563994+00:00 | 477 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe need to find the name and the number of different products sold on each date.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Select specific columns from the table.\n\n > `SELECT` \u2192 This command retr... | 5 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | Pandas | SQL | Easy | Explained Step By Step | Group Sold Products By The Date | pandas-sql-easy-explained-step-by-step-g-e7oy | see the successfully Accepted Solution\n\n\nimport pandas as pd\n\ndef categorize_products(activities: pd.DataFrame) -> pd.DataFrame:\n \n grouped_table = | Khosiyat | NORMAL | 2023-09-19T23:01:06.233175+00:00 | 2023-10-01T17:39:55.576285+00:00 | 133 | false | [see the successfully Accepted Solution](https://leetcode.com/submissions/detail/1054010892/)\n\n```\nimport pandas as pd\n\ndef categorize_products(activities: pd.DataFrame) -> pd.DataFrame:\n \n grouped_table = activities.groupby(\'sell_date\')\n statistics_product =grouped_table.agg(\n num_sold=(\'produc... | 5 | 0 | ['MySQL'] | 1 |
group-sold-products-by-the-date | SQL SERVER Solution | sql-server-solution-by-sharath_bayyaram-397l | it works well, and Don\'t forgot to upvote\n\nthis below line do magic\n\nstring_agg(product,\',\') within group (order by product asc) as products \n\n# Code\n | Sharath_Bayyaram | NORMAL | 2022-10-24T10:27:01.176689+00:00 | 2022-10-24T16:41:10.139524+00:00 | 831 | false | it works well, and **Don\'t forgot to upvote**\n\nthis below line do magic\n\n**string_agg(product,\',\') within group (order by product asc) as products **\n\n# Code\n```\n/* Write your T-SQL query statement below */\nselect sell_date, \n count(distinct product) as num_sold,\n string_agg(product,\',\') w... | 5 | 0 | ['MS SQL Server'] | 0 |
group-sold-products-by-the-date | ✅✅✅ Easiest and Understandable Solution | easiest-and-understandable-solution-by-l-fu6c | Write your MySQL query statement below\nSELECT \n sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINCT product ORDER BY product SE | Lyra_ | NORMAL | 2022-09-12T04:07:42.431993+00:00 | 2022-09-12T04:07:42.432054+00:00 | 882 | false | # Write your MySQL query statement below\nSELECT \n sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINCT product ORDER BY product SEPARATOR \',\') AS products\nFROM Activities\nGROUP BY sell_date | 5 | 0 | [] | 0 |
group-sold-products-by-the-date | Easy MySQL Query | Beginner friendly | easy-mysql-query-beginner-friendly-by-gp-3xlj | sql\nselect \n sell_date, \n count(distinct product) as num_sold, \n group_concat(distinct product) as products\nfrom activities\ngroup by sell_date\no | gparas | NORMAL | 2022-06-03T06:42:15.019827+00:00 | 2022-06-03T06:42:15.019880+00:00 | 469 | false | ```sql\nselect \n sell_date, \n count(distinct product) as num_sold, \n group_concat(distinct product) as products\nfrom activities\ngroup by sell_date\norder by sell_date;\n``` | 5 | 1 | [] | 0 |
group-sold-products-by-the-date | MySQL | Easy Solution | mysql-easy-solution-by-_dhruvbhatia-zyi7 | Pls Upvote if you like the solution!\n```\nSELECT sell_date,\n\t\tCOUNT(DISTINCT(product)) AS num_sold, \n\t\tGROUP_CONCAT(DISTINCT product ORDER BY product ASC | _dhruvbhatia_ | NORMAL | 2022-05-27T08:47:06.864755+00:00 | 2022-05-27T08:47:06.864798+00:00 | 447 | false | **Pls Upvote if you like the solution!**\n```\nSELECT sell_date,\n\t\tCOUNT(DISTINCT(product)) AS num_sold, \n\t\tGROUP_CONCAT(DISTINCT product ORDER BY product ASC SEPARATOR \',\') AS products\nFROM Activities\nGROUP BY sell_date\nORDER BY sell_date ASC | 5 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | Simple MySQL Solution beats 100 % | simple-mysql-solution-beats-100-by-arkap-1llw | \nSELECT\n\tsell_date,\n\tCOUNT(DISTINCT (product)) AS num_sold, \n\tGROUP_CONCAT(DISTINCT(product)) AS products \nFROM Activities \nGROUP BY sell_date \nORDER | arkapravagupta2002 | NORMAL | 2022-05-22T09:33:06.008742+00:00 | 2022-05-26T03:17:50.625926+00:00 | 564 | false | ```\nSELECT\n\tsell_date,\n\tCOUNT(DISTINCT (product)) AS num_sold, \n\tGROUP_CONCAT(DISTINCT(product)) AS products \nFROM Activities \nGROUP BY sell_date \nORDER BY sell_date ASC;\n```\nEdit : As someone pointed out in the comments, we could use ```GROUP_CONCAT(DISTINCT(product) ORDER BY product ASC)``` to sort the pr... | 5 | 0 | ['MySQL'] | 1 |
group-sold-products-by-the-date | quickest solution | quickest-solution-by-nirmalnk-s9hz | select sell_date, \ncount(distinct product) as num_sold, \ngroup_concat(distinct product) as products\nfrom Activities\ngroup by sell_date\norder by sell_date,p | nirmalnk | NORMAL | 2022-05-18T09:50:40.285536+00:00 | 2022-05-18T09:50:40.285560+00:00 | 417 | false | select sell_date, \ncount(distinct product) as num_sold, \ngroup_concat(distinct product) as products\nfrom Activities\ngroup by sell_date\norder by sell_date,products | 5 | 0 | ['MySQL'] | 2 |
group-sold-products-by-the-date | Oracle Solution - LISTAGG | oracle-solution-listagg-by-ppal87-ljkp | \nWITH cte as(\nselect distinct sell_date, product from Activities)\n\nselect TO_CHAR(sell_date,\'YYYY-MM-DD\') as sell_date, count(product) as num_sold,\nLISTA | ppal87 | NORMAL | 2020-06-18T13:45:38.075821+00:00 | 2020-06-18T13:45:38.075868+00:00 | 940 | false | ```\nWITH cte as(\nselect distinct sell_date, product from Activities)\n\nselect TO_CHAR(sell_date,\'YYYY-MM-DD\') as sell_date, count(product) as num_sold,\nLISTAGG(product, \',\') WITHIN GROUP (ORDER BY product) as products\nfrom cte\ngroup by sell_date\norder by sell_date\n``` | 5 | 0 | ['Oracle'] | 1 |
group-sold-products-by-the-date | Easy Beginner freindly solution || Deep Explaination. | easy-beginner-freindly-solution-deep-exp-oiqi | My solution aims to achieve the following tasks:\n\n1. Group by sell_date to get counts and concatenations of products sold on each date.\n2. Count distinct pro | Darshan_999 | NORMAL | 2024-07-17T06:31:14.685341+00:00 | 2024-07-17T06:31:14.685378+00:00 | 985 | false | My solution aims to achieve the following tasks:\n\n1. **Group by `sell_date`** to get counts and concatenations of products sold on each date.\n2. **Count distinct products** sold on each date.\n3. **Concatenate distinct product names** in ascending order, separated by commas.\n\nHere\'s a breakdown of the components ... | 4 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | 100 % || INTUITIVE && WELL - EXPLAINED || EASY SQL QUERY || Using GROUP_CONCAT( ) || Beats 89.11 %.. | 100-intuitive-well-explained-easy-sql-qu-vzh5 | Intuition\n Describe your first thoughts on how to solve this problem. \nSELECT sell_date, --> show sell_date...\nCOUNT(DISTINCT product) AS num_sold, --> Using | ganpatinath07 | NORMAL | 2024-02-14T17:11:58.345562+00:00 | 2024-02-14T17:11:58.345593+00:00 | 1,180 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSELECT sell_date, --> **show** sell_date...\nCOUNT(DISTINCT product) AS num_sold, --> Using **aggregate** function **COUNT** to count product only once **alias** as num_sold...\nGROUP_CONCAT(DISTINCT product ORDER BY product) --> it helps... | 4 | 0 | ['Database', 'MySQL'] | 0 |
group-sold-products-by-the-date | 💯SIMPLE | Explanation 2023🟢 | EASY💡 | simple-explanation-2023-easy-by-komronab-2wt6 | SELECT-> sell_date: This part of the query selects the sell_date column, which represents the date of sales activities.\n\nCOUNT-> (DISTINCT product) AS num_sol | komronabdulloev | NORMAL | 2023-10-15T08:24:20.008687+00:00 | 2023-10-15T08:24:20.008712+00:00 | 657 | false | `SELECT`-> sell_date: This part of the query selects the sell_date column, which represents the date of sales activities.\n\n`COUNT`-> (DISTINCT product) AS num_sold: This part counts the number of distinct products sold on each sell_date. The result is given the alias num_sold, which will represent the count of unique... | 4 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | MySQL Solution for Group Sold Products By The Date Problem | mysql-solution-for-group-sold-products-b-k9q4 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition behind the solution is to group the activities by sell date and then calc | Aman_Raj_Sinha | NORMAL | 2023-06-05T12:38:09.007795+00:00 | 2023-06-05T12:38:09.007832+00:00 | 1,258 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition behind the solution is to group the activities by sell date and then calculate the number of different products sold on each date. Additionally, we need to concatenate the names of the products and sort them lexicographicall... | 4 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | SQL Server CLEAN & EASY | sql-server-clean-easy-by-rhazem13-j7nd | \nWITH CTE AS (\n SELECT DISTINCT * FROM Activities\n)\n\nSELECT \nsell_date,\nCOUNT(product) AS num_sold,\nSTRING_AGG(product, \',\') WITHIN GROUP (ORDER BY p | rhazem13 | NORMAL | 2023-03-10T11:01:26.321865+00:00 | 2023-03-10T11:01:26.321905+00:00 | 1,671 | false | ```\nWITH CTE AS (\n SELECT DISTINCT * FROM Activities\n)\n\nSELECT \nsell_date,\nCOUNT(product) AS num_sold,\nSTRING_AGG(product, \',\') WITHIN GROUP (ORDER BY product ASC) AS products\nFROM CTE\nGROUP BY sell_date\nORDER BY 1 ASC\n``` | 4 | 0 | [] | 0 |
group-sold-products-by-the-date | SOLUTION WITH STRING_AGG FUNCTION ( SQL SERVER ) | solution-with-string_agg-function-sql-se-hg4h | Intuition\r\n Describe your first thoughts on how to solve this problem. \r\n\r\n# Approach\r\n Describe your approach to solving the problem. \r\n\r\n# Complex | cooking_Guy_9ice | NORMAL | 2023-03-05T14:46:17.054196+00:00 | 2023-03-05T14:46:17.054246+00:00 | 813 | false | # Intuition\r\n<!-- Describe your first thoughts on how to solve this problem. -->\r\n\r\n# Approach\r\n<!-- Describe your approach to solving the problem. -->\r\n\r\n# Complexity\r\n- Time complexity:\r\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\r\n\r\n- Space complexity:\r\n<!-- Add your space complexity ... | 4 | 0 | ['MS SQL Server'] | 0 |
group-sold-products-by-the-date | simple solution | simple-solution-by-shulingchang-dn2l | \nSELECT sell_date, \nCOUNT(DISTINCT(product)) AS num_sold, \nGROUP_CONCAT(DISTINCT(product)) AS products \nFROM Activities \nGROUP BY sell_date \nORDER BY sell | shulingchang | NORMAL | 2022-08-18T04:11:45.973158+00:00 | 2022-08-18T04:11:45.973198+00:00 | 799 | false | ```\nSELECT sell_date, \nCOUNT(DISTINCT(product)) AS num_sold, \nGROUP_CONCAT(DISTINCT(product)) AS products \nFROM Activities \nGROUP BY sell_date \nORDER BY sell_date;\n``` | 4 | 0 | [] | 2 |
group-sold-products-by-the-date | ✅[MySQL] Easy Solution using group_concat() | mysql-easy-solution-using-group_concat-b-3fzt | GROUP_CONCAT() function\n\nMySQL GROUP_CONCAT() function eturns a string with concatenated non-NULL value from a group.\nReturns NULL when there are no non-NULL | biT_Legion | NORMAL | 2022-08-07T10:58:53.623660+00:00 | 2022-08-07T10:58:53.623687+00:00 | 564 | false | ##### GROUP_CONCAT() function\n\nMySQL GROUP_CONCAT() function eturns a string with concatenated non-NULL value from a group.\nReturns NULL when there are no non-NULL values.\n\n\n```\nselect sell_date, \n\tcount(distinct(product)) as num_sold, \n\t\tgroup_concat(distinct(product)) as products\nfrom activities\ngroup b... | 4 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | simple readable group by solution | simple-readable-group-by-solution-by-ujj-gxfk | \n# Write your MySQL query statement below\nselect sell_date, count(distinct product) num_sold, \ngroup_concat(distinct product) as products from Activities gro | ujjwalavishek | NORMAL | 2022-07-26T06:17:46.771052+00:00 | 2022-07-26T06:17:46.771096+00:00 | 420 | false | ```\n# Write your MySQL query statement below\nselect sell_date, count(distinct product) num_sold, \ngroup_concat(distinct product) as products from Activities group by sell_date\n``` | 4 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | MySQL | Easy-Understanding | Beginner-Friendly | mysql-easy-understanding-beginner-friend-8v2t | \nselect sell_date,\n\t count(distinct product) as num_sold,\n group_concat(distinct product) as products\nfrom activities\ngroup by sell_date\norder | Saiko15 | NORMAL | 2022-07-12T09:03:36.825127+00:00 | 2022-07-12T09:03:36.825169+00:00 | 537 | false | ```\nselect sell_date,\n\t count(distinct product) as num_sold,\n group_concat(distinct product) as products\nfrom activities\ngroup by sell_date\norder by sell_date\n``` | 4 | 0 | ['MySQL'] | 1 |
group-sold-products-by-the-date | 1484. Group Sold Products By The Date | 1484-group-sold-products-by-the-date-by-4ki9n | \nselect sell_date,\ncount(distinct product)as num_sold,\ngroup_concat(distinct product order by product) as products\nfrom Activities \ngroup by sell_date\nord | rudra_0726 | NORMAL | 2022-07-11T03:19:39.437252+00:00 | 2022-07-11T03:19:39.437292+00:00 | 1,288 | false | ```\nselect sell_date,\ncount(distinct product)as num_sold,\ngroup_concat(distinct product order by product) as products\nfrom Activities \ngroup by sell_date\norder by sell_date;\n\n``` | 4 | 0 | ['MySQL', 'Oracle'] | 0 |
group-sold-products-by-the-date | GROUP_CONCAT ( ) FASTER THAN 95% | group_concat-faster-than-95-by-raghav_sh-sbr2 | \nSELECT sell_date, \nCOUNT(DISTINCT product) num_sold, \nGROUP_CONCAT(DISTINCT product) as products\nFROM Activities\nGROUP BY 1\n\n\nI am not sure if we have | Raghav_Shandilya | NORMAL | 2022-06-17T06:32:01.640433+00:00 | 2022-06-17T06:32:01.640462+00:00 | 336 | false | ```\nSELECT sell_date, \nCOUNT(DISTINCT product) num_sold, \nGROUP_CONCAT(DISTINCT product) as products\nFROM Activities\nGROUP BY 1\n```\n\nI am not sure if we have to use ORDER BY within GROUP_CONCAT as it returns the order lexicographically on its own. My assumption is that ---> ASC order is by default if you dont m... | 4 | 0 | [] | 1 |
group-sold-products-by-the-date | [MySQL] BEATS 100.00% MEMORY/SPEED 0ms // APRIL 2022 | mysql-beats-10000-memoryspeed-0ms-april-l18y1 | \nSELECT sell_date,\n\t\tCOUNT(DISTINCT(product)) AS num_sold, \n\t\tGROUP_CONCAT(DISTINCT product ORDER BY product ASC SEPARATOR \',\') AS products\nFROM Activ | darian-catalin-cucer | NORMAL | 2022-04-23T09:27:32.489461+00:00 | 2022-04-23T09:27:32.489507+00:00 | 428 | false | ```\nSELECT sell_date,\n\t\tCOUNT(DISTINCT(product)) AS num_sold, \n\t\tGROUP_CONCAT(DISTINCT product ORDER BY product ASC SEPARATOR \',\') AS products\nFROM Activities\nGROUP BY sell_date\nORDER BY sell_date ASC\n``` | 4 | 0 | ['MySQL'] | 1 |
group-sold-products-by-the-date | MYSQL Solution distict , group_concat ,group by | mysql-solution-distict-group_concat-grou-9blh | \nselect \n sell_date,\n count(distinct(product)) as num_sold,\n group_concat(distinct(product)) as products \nfrom Activities \n group by sell_dat | Sulaymon-Dev20 | NORMAL | 2022-04-23T08:40:34.523894+00:00 | 2022-04-23T08:41:08.727315+00:00 | 131 | false | ```\nselect \n sell_date,\n count(distinct(product)) as num_sold,\n group_concat(distinct(product)) as products \nfrom Activities \n group by sell_date \n``` | 4 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | Oracle | Listagg | group by | oracle-listagg-group-by-by-gowthamguttul-vmen | Please upvote, if it helps\n\n\nselect to_char(sell_date) sell_date,count(1)num_sold,LISTAGG(product,\',\') within group (order by product) products from (selec | GowthamGuttula | NORMAL | 2022-04-12T06:22:44.522459+00:00 | 2022-04-12T06:22:44.522508+00:00 | 892 | false | Please upvote, if it helps\n\n```\nselect to_char(sell_date) sell_date,count(1)num_sold,LISTAGG(product,\',\') within group (order by product) products from (select distinct * from Activities) group by sell_date order by sell_date\n``` | 4 | 0 | ['Oracle'] | 0 |
group-sold-products-by-the-date | MS SQL | ms-sql-by-siyu14-hdfb | Question\n\n1484. Group Sold Products By The Date\nEasy\n\nSQL Schema\nTable Activities:\n\n+-------------+---------+\n| Column Name | Type |\n+------------- | siyu14 | NORMAL | 2021-10-13T20:17:05.075210+00:00 | 2021-10-13T20:17:05.075254+00:00 | 984 | false | #### Question\n```\n1484. Group Sold Products By The Date\nEasy\n\nSQL Schema\nTable Activities:\n\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| sell_date | date |\n| product | varchar |\n+-------------+---------+\nThere is no primary key for this table, it may contains du... | 4 | 0 | ['MS SQL Server'] | 0 |
group-sold-products-by-the-date | [MySQL] | mysql-by-ye15-qxnv | \n\nSELECT sell_date, COUNT(DISTINCT product) AS num_sold, GROUP_CONCAT(DISTINCT product ORDER BY product ASC) AS products\nFROM Activities\nGROUP BY sell_date\ | ye15 | NORMAL | 2021-01-22T02:29:19.924776+00:00 | 2021-01-22T02:29:19.924827+00:00 | 453 | false | \n```\nSELECT sell_date, COUNT(DISTINCT product) AS num_sold, GROUP_CONCAT(DISTINCT product ORDER BY product ASC) AS products\nFROM Activities\nGROUP BY sell_date\n``` | 4 | 0 | ['MySQL'] | 1 |
group-sold-products-by-the-date | Easy Oracle solution using LISTAGG | easy-oracle-solution-using-listagg-by-pr-1ufu | \nselect \n(to_char(sell_date,\'YYYY-MM-DD\')) as sell_date,\ncount(product) as num_sold,listagg(product,\',\') WITHIN GROUP (ORDER BY product) as products\nfro | praveenpurwar2004 | NORMAL | 2020-06-18T19:14:23.331351+00:00 | 2020-06-18T19:14:23.331475+00:00 | 264 | false | ```\nselect \n(to_char(sell_date,\'YYYY-MM-DD\')) as sell_date,\ncount(product) as num_sold,listagg(product,\',\') WITHIN GROUP (ORDER BY product) as products\nfrom (select distinct sell_date,product from Activities)\ngroup by sell_date\n``` | 4 | 0 | [] | 0 |
group-sold-products-by-the-date | [PostgreSQL] STRING_AGG | postgresql-string_agg-by-pbelskiy-yxwh | \nSELECT \n sell_date, \n COUNT(DISTINCT product) AS num_sold,\n STRING_AGG(DISTINCT product, \',\') AS products\nFROM Activities\nGROUP BY sell_date\nORDER | pbelskiy | NORMAL | 2024-06-05T19:16:34.283150+00:00 | 2024-06-05T19:16:34.283199+00:00 | 330 | false | ```\nSELECT \n sell_date, \n COUNT(DISTINCT product) AS num_sold,\n STRING_AGG(DISTINCT product, \',\') AS products\nFROM Activities\nGROUP BY sell_date\nORDER BY sell_date\n\n``` | 3 | 0 | ['PostgreSQL'] | 0 |
group-sold-products-by-the-date | SQL: Daily Product Sales Summary | sql-daily-product-sales-summary-by-aleos-630r | \n# Code\n\nSELECT \n sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINCT product ORDER BY product SEPARATOR \',\') AS products\n | aleos-dev | NORMAL | 2024-01-04T18:08:49.025599+00:00 | 2024-01-04T18:08:49.025625+00:00 | 869 | false | \n# Code\n```\nSELECT \n sell_date,\n COUNT(DISTINCT product) AS num_sold,\n GROUP_CONCAT(DISTINCT product ORDER BY product SEPARATOR \',\') AS products\nFROM activities\nGROUP BY sell_date\nORDER BY sell_date ASC;\n\n```\n\n##### GROUP_CONCAT Function\n```\nGROUP_CONCAT(column_name ORDER BY some_column SEPARA... | 3 | 0 | ['MySQL'] | 1 |
group-sold-products-by-the-date | T-SQL | Simple Solution | WITH & COUNT & STRING_AGG & WITHIN | t-sql-simple-solution-with-count-string_-p3b8 | Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co | ilyastuit | NORMAL | 2023-08-24T08:55:42.159449+00:00 | 2023-08-25T06:39:32.601236+00:00 | 1,445 | false | # Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```sql\nWITH t AS (SELECT DISTINCT * FROM Activities)\n\nSELECT \n t.sell_date,\n COUNT(t.product) AS num_sold,\n S... | 3 | 0 | ['Database', 'MS SQL Server'] | 2 |
group-sold-products-by-the-date | Using group by and agg functions | using-group-by-and-agg-functions-by-chv5-k9r1 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | chv532 | NORMAL | 2023-08-22T16:19:03.926503+00:00 | 2023-08-22T16:19:03.926525+00:00 | 567 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 3 | 0 | ['Pandas'] | 0 |
group-sold-products-by-the-date | T-SQL STRING_AGG function used | t-sql-string_agg-function-used-by-user07-jinu | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | user0747y | NORMAL | 2023-05-12T05:02:51.336826+00:00 | 2023-05-12T05:02:51.336869+00:00 | 1,149 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 3 | 0 | ['MS SQL Server'] | 0 |
group-sold-products-by-the-date | MySQL Solution | mysql-solution-by-pranto1209-04jp | Code\n\n# Write your MySQL query statement below\nselect sell_date, count(distinct(product)) as num_sold, \ngroup_concat(distinct(product) order by product) as | pranto1209 | NORMAL | 2023-03-07T18:44:28.792882+00:00 | 2023-03-07T18:44:28.792924+00:00 | 1,838 | false | # Code\n```\n# Write your MySQL query statement below\nselect sell_date, count(distinct(product)) as num_sold, \ngroup_concat(distinct(product) order by product) as products\nfrom Activities group by sell_date order by sell_date;\n``` | 3 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | MySQL🐬89.2% FASTER🏎💨 | mysql892-faster-by-shubhamdraj-je2e | Approach\n Describe your approach to solving the problem. \nThe challange of this problem is how to aggregate the product names in one cell. So we use GROUP_CON | shubhamdraj | NORMAL | 2022-11-08T16:01:29.260819+00:00 | 2022-11-08T16:01:29.260859+00:00 | 720 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nThe challange of this problem is how to aggregate the product names in one cell. So we use `GROUP_CONCAT()` to aggregate distinct product names with a separator \',\' and also sort the product names. The rest is simple, we group by sell_date and COUNT... | 3 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | just use group_concat | just-use-group_concat-by-takjaknigdy-trxf | \nselect \n\tsell_date, \n\tcount(distinct product) as num_sold, \n\tgroup_concat(distinct product) as products\nfrom Activities\ngroup by sell_date\norder by s | takjaknigdy | NORMAL | 2022-09-22T21:26:57.472648+00:00 | 2022-09-22T21:26:57.472690+00:00 | 287 | false | ```\nselect \n\tsell_date, \n\tcount(distinct product) as num_sold, \n\tgroup_concat(distinct product) as products\nfrom Activities\ngroup by sell_date\norder by sell_date\n``` | 3 | 0 | [] | 0 |
group-sold-products-by-the-date | Group products using new STRING_AGG funtion | group-products-using-new-string_agg-funt-sljg | Upvote if you feel it easy :)\n\nThis solution uses latest function STRING_AGG introduced by sql server\n\nSELECT x.sell_date, SUM(x.num_sold) AS num_sold, STRI | user1652uo | NORMAL | 2022-09-10T17:25:02.068662+00:00 | 2022-09-15T16:56:10.295363+00:00 | 663 | false | **Upvote if you feel it easy :)**\n\nThis solution uses latest function STRING_AGG introduced by sql server\n```\nSELECT x.sell_date, SUM(x.num_sold) AS num_sold, STRING_AGG(x.product,\',\') as products\nFROM (\n\tSELECT top 100 percent sell_date, COUNT(DISTINCT product) as num_sold, product\n\tFROM Activities\n\tGROUP... | 3 | 0 | ['MS SQL Server'] | 0 |
group-sold-products-by-the-date | simple and easy | simple-and-easy-by-aman_verma-sqik | select sell_date,count(distinct product) num_sold,group_concat(distinct product) products from activities group by sell_date order by sell_date | aman_verma_ | NORMAL | 2022-09-08T06:54:53.652380+00:00 | 2022-09-08T06:54:53.652426+00:00 | 834 | false | select sell_date,count(distinct product) num_sold,group_concat(distinct product) products from activities group by sell_date order by sell_date | 3 | 0 | ['MySQL'] | 1 |
group-sold-products-by-the-date | Group_Concat function | Easy to Understand | MySQL Solution | group_concat-function-easy-to-understand-nuba | \nSELECT\n sell_date,\n COUNT(DISTINCT product) AS "num_sold",\n GROUP_CONCAT(\n DISTINCT product\n ORDER BY\n product\n ) | deleted_user | NORMAL | 2022-07-20T02:27:48.182731+00:00 | 2022-07-20T02:27:48.182760+00:00 | 418 | false | ```\nSELECT\n sell_date,\n COUNT(DISTINCT product) AS "num_sold",\n GROUP_CONCAT(\n DISTINCT product\n ORDER BY\n product\n ) AS "products"\nFROM\n activities\nGROUP BY\n sell_date;\n``` | 3 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | SQL Query using string_agg | sql-query-using-string_agg-by-lavinamall-xjtw | \nSELECT sell_date, \n COUNT(product) AS num_sold, \n STRING_AGG(product,\',\') WITHIN GROUP ( ORDER BY product ASC) AS products\nFROM (SELECT DISTINCT se | lavinamall | NORMAL | 2022-07-15T10:52:43.124836+00:00 | 2022-07-15T10:52:43.124873+00:00 | 709 | false | ```\nSELECT sell_date, \n COUNT(product) AS num_sold, \n STRING_AGG(product,\',\') WITHIN GROUP ( ORDER BY product ASC) AS products\nFROM (SELECT DISTINCT sell_date, product FROM Activities)A\nGROUP BY sell_date\n``` | 3 | 0 | ['MySQL', 'MS SQL Server'] | 0 |
group-sold-products-by-the-date | Group Sold Products By The Date | group-sold-products-by-the-date-by-kshit-ebz9 | \nSELECT sell_date,\nCOUNT(distinct(product)) AS num_sold,\nGROUP_CONCAT(DISTINCT(product) ORDER BY product SEPARATOR \',\') as products\nFROM Activities\nGROUP | kshitij_thakre | NORMAL | 2022-07-01T12:53:25.088593+00:00 | 2022-07-01T12:53:25.088644+00:00 | 387 | false | ```\nSELECT sell_date,\nCOUNT(distinct(product)) AS num_sold,\nGROUP_CONCAT(DISTINCT(product) ORDER BY product SEPARATOR \',\') as products\nFROM Activities\nGROUP BY sell_date\nORDER BY sell_date,product;\n``` | 3 | 0 | ['MySQL'] | 1 |
group-sold-products-by-the-date | MySQl Solution | Group Sold Products By The Date | mysql-solution-group-sold-products-by-th-aqic | In this question , we need to group our data based on the selling date and we need to provide date and number of product sell at that day in the output :\n | manavi2000y | NORMAL | 2022-06-20T06:51:54.767445+00:00 | 2022-06-20T06:51:54.767485+00:00 | 393 | false | In this question , we need to group our data based on the selling date and we need to provide date and number of product sell at that day in the output :\n \n\t\t\t SELECT \n sell_date , \n COUNT(DISTINCT product) AS num_sold , \n FROM activiti... | 3 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | You got it | you-got-it-by-gogole-xyiw | select sell_date , Count(distinct product) \'num_sold\' ,\nGroup_concat(Distinct product order by product) \'products\'\nfrom activities group by sell_date; | GOGOLE | NORMAL | 2022-06-13T04:16:24.469972+00:00 | 2022-06-13T04:16:24.470012+00:00 | 250 | false | select sell_date , Count(distinct product) \'num_sold\' ,\nGroup_concat(Distinct product order by product) \'products\'\nfrom activities group by sell_date; | 3 | 0 | [] | 1 |
group-sold-products-by-the-date | concat 95% | concat-95-by-lightningmcqueenkachow-40bs | \nselect\n sell_date, \n count(distinct product) as num_sold, \n group_concat(distinct product order by product asc) as products \nfrom \n activitie | lightningMcqueenKachow | NORMAL | 2022-05-14T23:20:55.474016+00:00 | 2022-05-14T23:20:55.474048+00:00 | 203 | false | ```\nselect\n sell_date, \n count(distinct product) as num_sold, \n group_concat(distinct product order by product asc) as products \nfrom \n activities \ngroup by \n sell_date\norder by \n sell_date \n```\n\nif you like this, please upvote. | 3 | 0 | [] | 1 |
group-sold-products-by-the-date | TSQL STRING_AGG statement | tsql-string_agg-statement-by-yulinchao-fui6 | \nSELECT sell_date, COUNT(DISTINCT(product)) AS num_sold, \n STRING_AGG(product,\',\') WITHIN GROUP (ORDER BY product) AS products\nFROM \n(SELECT DISTINCT s | yulinchao | NORMAL | 2022-05-12T09:24:30.180756+00:00 | 2022-05-12T09:24:30.180797+00:00 | 146 | false | ```\nSELECT sell_date, COUNT(DISTINCT(product)) AS num_sold, \n STRING_AGG(product,\',\') WITHIN GROUP (ORDER BY product) AS products\nFROM \n(SELECT DISTINCT sell_date, product FROM Activities) T\nGROUP BY sell_date\n``` | 3 | 0 | [] | 0 |
group-sold-products-by-the-date | easy solution - distinct, group_concat, group by | easy-solution-distinct-group_concat-grou-mcdi | SELECT sell_date, count(distinct product) as num_sold, group_concat(distinct product) as products\nFROM activities\nGROUP BY sell_date; | anhdang1 | NORMAL | 2022-04-25T07:26:28.513573+00:00 | 2022-04-25T07:26:28.513612+00:00 | 355 | false | SELECT sell_date, count(distinct product) as num_sold, group_concat(distinct product) as products\nFROM activities\nGROUP BY sell_date; | 3 | 0 | [] | 0 |
group-sold-products-by-the-date | Using GROUP_CONCAT | Easy Understanding | SQL | using-group_concat-easy-understanding-sq-nhiu | The main problem here is to concatenate the distinct products that were sold on a particular date. \n\nWe can do that by using GROUP_CONCAT keyword.\nWe provide | raahulsaxena | NORMAL | 2022-04-11T14:29:59.102140+00:00 | 2022-04-11T14:29:59.102186+00:00 | 393 | false | The main problem here is to concatenate the distinct products that were sold on a particular date. \n\nWe can do that by using ```GROUP_CONCAT``` keyword.\nWe provide the `DISTINCT` keyword in both count and group_concat functions because we don\'t want any duplicate records to mess with our counts. (Question does ment... | 3 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | MySQL using COUNT, GROUP_CONTACT | mysql-using-count-group_contact-by-lahar-b6s1 | \nselect sell_date, count(distinct product) num_sold, \ngroup_concat(distinct product order by product) \nproducts from Activities group by sell_date;\n | lahari_bitra | NORMAL | 2022-03-25T11:23:11.883543+00:00 | 2022-03-25T11:23:11.883581+00:00 | 416 | false | ```\nselect sell_date, count(distinct product) num_sold, \ngroup_concat(distinct product order by product) \nproducts from Activities group by sell_date;\n``` | 3 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | Simple solution using group_concat in mysql | simple-solution-using-group_concat-in-my-dva7 | \nselect sell_date, \n count(distinct product) as num_sold,\n group_concat(distinct product order by product) as products\nfrom Activities\ngroup | ronakgadia | NORMAL | 2022-03-01T20:12:55.803413+00:00 | 2022-03-01T20:12:55.803444+00:00 | 332 | false | ```\nselect sell_date, \n count(distinct product) as num_sold,\n group_concat(distinct product order by product) as products\nfrom Activities\ngroup by sell_date\norder by sell_date\n``` | 3 | 0 | [] | 0 |
group-sold-products-by-the-date | MySQL | mysql-by-kool_panda-55ai | \nselect distinct sell_date, count(distinct product) as num_sold, \ngroup_concat(distinct product order by product) as products\nfrom activities \ngroup by sell | kool_panda | NORMAL | 2021-11-30T22:10:50.896441+00:00 | 2021-11-30T22:10:50.896475+00:00 | 564 | false | ```\nselect distinct sell_date, count(distinct product) as num_sold, \ngroup_concat(distinct product order by product) as products\nfrom activities \ngroup by sell_date\norder by sell_date\n``` | 3 | 0 | [] | 0 |
group-sold-products-by-the-date | 99.84% faster | 9984-faster-by-jonathanli42-i6hs | SELECT\n sell_date, \n\tCOUNT(DISTINCT product) AS num_sold, \n\tGROUP_CONCAT(DISTINCT product ORDER BY product ASC) AS products\nFROM\n Activities\nGROUP | jonathanli42 | NORMAL | 2020-10-24T05:19:21.646635+00:00 | 2020-10-24T05:19:21.646668+00:00 | 620 | false | SELECT\n sell_date, \n\tCOUNT(DISTINCT product) AS num_sold, \n\tGROUP_CONCAT(DISTINCT product ORDER BY product ASC) AS products\nFROM\n Activities\nGROUP BY 1\nORDER BY 1 ASC\n | 3 | 1 | [] | 1 |
group-sold-products-by-the-date | simple mysql answer | simple-mysql-answer-by-plh2-cz2u | answer 1\n> Runtime: 729 ms, faster than 25.00% of MySQL online submissions for Group Sold Products By The Date.\nMemory Usage: 0B, less than 100.00% of MySQL o | plh2 | NORMAL | 2020-07-05T08:24:34.022739+00:00 | 2020-07-05T08:27:38.020188+00:00 | 675 | false | # answer 1\n> Runtime: 729 ms, faster than 25.00% of MySQL online submissions for Group Sold Products By The Date.\nMemory Usage: 0B, less than 100.00% of MySQL online submissions for Group Sold Products By The Date.\n\n```sql\nselect \n\tsell_date, \n\tCOUNT(product) num_sold, \n\tgroup_concat(product order by produc... | 3 | 0 | [] | 2 |
group-sold-products-by-the-date | MSSQL + XML PATH | mssql-xml-path-by-domicilio2114-h62s | \n1. Distinct Rows\n\t\tselect distinct * from activities\n\n\n2. XML Path\n\t\tselect \',\' + tb1.product from (select distinct * from activities) tb1 for XML | domicilio2114 | NORMAL | 2020-06-29T07:01:55.448875+00:00 | 2020-06-29T07:01:55.448924+00:00 | 332 | false | ```\n1. Distinct Rows\n\t\tselect distinct * from activities\n```\n```\n2. XML Path\n\t\tselect \',\' + tb1.product from (select distinct * from activities) tb1 for XML path(\'\')\n```\n```\n3. Add Stuff\n\t\tselect products = stuff((select \',\' + a.product from (select distinct * from activities) a for XML path(\'\')... | 3 | 0 | [] | 2 |
group-sold-products-by-the-date | SQL Server | sql-server-by-adchoudhary-0785 | Code | adchoudhary | NORMAL | 2025-03-09T04:31:47.780617+00:00 | 2025-03-09T04:31:47.780617+00:00 | 473 | false | # Code
```mssql []
/* Write your T-SQL query statement below */
WITH t AS (SELECT DISTINCT * FROM Activities)
SELECT
t.sell_date,
COUNT(t.product) AS num_sold,
STRING_AGG(t.product, ',') WITHIN GROUP (ORDER BY t.product) as products
FROM t
GROUP BY sell_date
ORDER BY sell_date
``` | 2 | 0 | ['MS SQL Server'] | 0 |
group-sold-products-by-the-date | MySQL solution using - GROUP_CONCAT | mysql-solution-using-group_concat-by-swa-2lu2 | Code | swapit | NORMAL | 2025-02-28T11:03:55.984811+00:00 | 2025-02-28T11:03:55.984811+00:00 | 437 | false | # Code
```mysql []
SELECT sell_date, COUNT(DISTINCT(product)) AS num_sold, GROUP_CONCAT(DISTINCT product,'') AS products
FROM Activities
GROUP BY sell_date
``` | 2 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | Easy explanation | easy-explanation-by-pratyushpanda91-ggtk | ExplanationGrouping by sell_dateGROUP BY sell_date ensures we aggregate products per date.
Counting Distinct Products Sold Per DateCOUNT(DISTINCT product) AS nu | pratyushpanda91 | NORMAL | 2025-02-17T16:31:54.256604+00:00 | 2025-02-17T16:31:54.256604+00:00 | 664 | false | # Explanation
Grouping by sell_date
GROUP BY sell_date ensures we aggregate products per date.
Counting Distinct Products Sold Per Date
COUNT(DISTINCT product) AS num_sold counts the unique products sold for each date.
Concatenating Product Names in Lexicographical Order
GROUP_CONCAT(DISTINCT product ORDER BY produc... | 2 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | Group_concat | group_concat-by-aadithya18-5ado | IntuitionActually, I am also new to this. Seen a hint from the discussion section and found out there is group_concat available in sql.Code | aadithya18 | NORMAL | 2025-02-10T20:58:27.927582+00:00 | 2025-02-10T20:58:27.927582+00:00 | 375 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Actually, I am also new to this. Seen a hint from the discussion section and found out there is group_concat available in sql.
# Code
```mysql []
# Write your MySQL query statement below
Select
a.sell_date, Count(distinct(a.product)) ... | 2 | 0 | ['Database', 'MySQL'] | 0 |
group-sold-products-by-the-date | ✅✅100% working solution 🔥🔥using GROUP_CONCAT || | 100-working-solution-using-group_concat-lfhpo | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | ritikg4360 | NORMAL | 2025-02-01T10:50:58.860397+00:00 | 2025-02-01T10:50:58.860397+00:00 | 456 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 2 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | 👉🏻EASY TO UNDERSTAND SOLUTION || FAST || COUNT() || GROUP_CONCAT() || MySQL | easy-to-understand-solution-fast-count-g-rfp0 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | Siddarth9911 | NORMAL | 2025-01-04T18:23:29.447505+00:00 | 2025-01-04T18:23:29.447505+00:00 | 447 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 2 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | EASY WAY USING GROUP_CONCAT | easy-way-using-group_concat-by-siddu_pat-83ll | \n# Code\nmysql []\nselect sell_date,\ncount(distinct product)as num_sold,\ngroup_concat(distinct product order by product) as products\nfrom Activities \ngroup | siddu_patil005 | NORMAL | 2024-11-29T13:34:40.858690+00:00 | 2024-11-29T13:34:40.858713+00:00 | 400 | false | \n# Code\n```mysql []\nselect sell_date,\ncount(distinct product)as num_sold,\ngroup_concat(distinct product order by product) as products\nfrom Activities \ngroup by sell_date\norder by sell_date;\n``` | 2 | 0 | ['MySQL'] | 0 |
group-sold-products-by-the-date | 📊 Efficient SQL Solution for Grouped Product Count and Concatenation 🏆 (Beats 91% in Speed!) | efficient-sql-solution-for-grouped-produ-nb3u | \uD83D\uDCCA SQL Solution for Grouping and Counting Sold Products \uD83C\uDFC6\n\n### Intuition\n Describe your first thoughts on how to solve this problem. \nT | rshikharev | NORMAL | 2024-11-07T15:54:28.822560+00:00 | 2024-11-07T15:54:28.822594+00:00 | 572 | false | ## \uD83D\uDCCA SQL Solution for Grouping and Counting Sold Products \uD83C\uDFC6\n\n### Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal is to find the number of unique products sold for each date and list them in lexicographical order.\n\n### Approach\n<!-- Describe your approa... | 2 | 0 | ['Database', 'MySQL'] | 0 |
complement-of-base-10-integer | Solution | solution-by-deleted_user-b37f | C++ []\nclass Solution {\n public:\n int bitwiseComplement(int N) {\n int mask = 1;\n\n while (mask < N)\n mask = (mask << 1) + 1;\n\n return mas | deleted_user | NORMAL | 2023-05-20T07:49:01.127884+00:00 | 2023-05-20T08:13:42.329372+00:00 | 7,395 | false | ```C++ []\nclass Solution {\n public:\n int bitwiseComplement(int N) {\n int mask = 1;\n\n while (mask < N)\n mask = (mask << 1) + 1;\n\n return mask ^ N;\n }\n};\n```\n\n```Python3 []\nclass Solution:\n def bitwiseComplement(self, n: int) -> int:\n cnt=0\n ans=0\n if n==0:\n ... | 466 | 0 | ['C++', 'Java', 'Python3'] | 4 |
complement-of-base-10-integer | [Java/C++/Python] Find 111.....1111 >= N | javacpython-find-1111111-n-by-lee215-vgm0 | Hints\n1. what is the relationship between input and output\n2. input + output = 111....11 in binary format\n3. Is there any corner case?\n4. 0 is a corner case | lee215 | NORMAL | 2019-03-17T04:02:27.659592+00:00 | 2019-07-07T12:38:35.215299+00:00 | 20,691 | false | ## **Hints**\n1. what is the relationship between input and output\n2. input + output = 111....11 in binary format\n3. Is there any corner case?\n4. 0 is a corner case expecting 1, output > input\n\n\n## **Intuition**\nLet\'s find the first number `X` that `X = 1111....1 > N`\nAnd also, it has to be noticed that,\n`N =... | 321 | 4 | [] | 21 |
complement-of-base-10-integer | C++ EASY TO SOLVE || Beginner friendly with detailed explanation and dry run | c-easy-to-solve-beginner-friendly-with-d-dx7a | Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation i.e if it\'s 101 =Complement=> | Cosmic_Phantom | NORMAL | 2022-01-04T02:30:48.071484+00:00 | 2024-08-23T02:25:07.500595+00:00 | 7,364 | false | Given a positive integer, output its **complement number**. The complement strategy is to flip the bits of its binary representation i.e if it\'s **101** =Complement=> **010**\n\n**Intuition:-**\nThere is not much of a intuition in this question as the question is loud and clear about it\'s use of bit manipulation .\n\... | 120 | 50 | ['Bit Manipulation', 'C', 'Bitmask', 'C++'] | 9 |
complement-of-base-10-integer | C++ 2 lines, XOR mask | c-2-lines-xor-mask-by-votrubac-8g5q | We construct a XOR mask from all ones until it\'s larger or equal than the number. For example, for 100101, the mask will be 111111. And for 1111, the mask will | votrubac | NORMAL | 2019-03-17T04:00:28.157284+00:00 | 2019-03-17T04:00:28.157319+00:00 | 10,004 | false | We construct a XOR mask from all ones until it\'s larger or equal than the number. For example, for ```100101```, the mask will be ```111111```. And for ```1111```, the mask will be ```1111```.\n\nThe result is the XOR operation of the number and the mask.\n```\nint bitwiseComplement(int N, int c = 1) {\n while (c < N... | 118 | 6 | [] | 9 |
complement-of-base-10-integer | Well Explained JAVA & C++ || 2 Approaches || Easy for mind to Accept it | well-explained-java-c-2-approaches-easy-8e2cz | Intitution\n\nWe have to convert 5 -----> 101 -----> 010 ------> 2\nSteps: 1 2 3\n\n\n\nMethod - 1 :\nApproach to use:\n\n | hi-malik | NORMAL | 2022-01-04T01:46:11.509527+00:00 | 2022-01-04T05:23:12.006494+00:00 | 6,511 | false | **Intitution**\n```\nWe have to convert 5 -----> 101 -----> 010 ------> 2\nSteps: 1 2 3\n```\n\n\n**Method - 1 :**\n**Approach to use:**\n```\nNow we take modulo of 5 i.e. % 2 ----> 1 ^\n\t\t\t\t\t\t\t\t2 ----> 0 |\n\t\t\t\t\t\t\t\t1 ----> 1 |\n\t\tand finally it becom... | 83 | 13 | ['C', 'Java'] | 14 |
complement-of-base-10-integer | 4 approaches: bitwise operation, math formular, one naive simulation, and bonus | 4-approaches-bitwise-operation-math-form-ns9g | Find the smallest binary number c that is all 1s, (e.g. \u201C111\u201D, \u201C11111\u201D) that is greater or equal to N.\nans = C ^ N or C \u2013 N\n\nMore de | codedayday | NORMAL | 2020-05-04T15:19:22.775885+00:00 | 2020-10-05T14:23:48.800864+00:00 | 4,489 | false | Find the smallest binary number c that is all 1s, (e.g. \u201C111\u201D, \u201C11111\u201D) that is greater or equal to N.\nans = C ^ N or C \u2013 N\n\nMore details:\n^: bitwise XOR operator\n**Table 1. The truth table of bitwise XOR operator:**\n**1^0 = 1\n1^1 = 0**\n0^0 = 0\n0^1 = 1\n**The upper two rows of Table 1... | 79 | 2 | ['Simulation'] | 3 |
complement-of-base-10-integer | ☕️ [C++,Java,Python ] | Easy Solution | MASK+XOR | 100% | cjavapython-easy-solution-maskxor-100-by-rjlm | C++ | Mask + XOR\nLogic: In order to find the complement of an integer we have to flip all the 0\'s to 1\'sand all the 1\'s to 0\'s. We know that XOR means one | coderaky | NORMAL | 2022-01-04T02:03:06.823748+00:00 | 2022-01-04T14:41:26.260540+00:00 | 2,437 | false | # C++ | Mask + XOR\n**Logic:** In order to find the complement of an integer we have to flip all the ``0\'s`` to ``1\'s ``and all the ``1\'s`` to ``0\'s``. We know that XOR means one or the other is true but not both. So if we XOR our input with a mask ``11111...``, flipping will happen and we will get our the desired ... | 69 | 42 | ['Bit Manipulation'] | 6 |
complement-of-base-10-integer | ✅ [C++/Python/Java] 1 Line || O(1) || Log and Bit OP || Detailed Explanation | cpythonjava-1-line-o1-log-and-bit-op-det-4j6q | PLEASE UPVOTE if you like \uD83D\uDE01 If you have any question, feel free to ask. \n step 1: get the mask of all 1s with the number of binary digits equal to t | linfq | NORMAL | 2022-01-04T05:10:13.069090+00:00 | 2022-01-04T06:30:43.305079+00:00 | 3,090 | false | **PLEASE UPVOTE if you like** \uD83D\uDE01 **If you have any question, feel free to ask.** \n* step 1: get the `mask` of all 1s with the number of binary digits equal to the number of binary digits of n\n\t* for example\n\t\t* `n = 5 = 0b101` so the number of binary digits is `3` and we get `mask = 0b111 = 7`\n\t\t* `n... | 57 | 28 | ['C', 'Python', 'Java'] | 9 |
complement-of-base-10-integer | ♾️ C++ | ✅100% Beats | ✅Full Explanation | 1009. Complement of Base 10 Integer | c-100-beats-full-explanation-1009-comple-124u | \n\n# \u2B06\uFE0FPlease Upvote If You Like the Solution :)\n\n# Approach\n1. We know that we need to complement. For that we need to change 0 to 1 and 1 to 0.\ | AnantKumawat22 | NORMAL | 2023-05-26T11:00:03.224713+00:00 | 2023-05-26T13:59:52.147595+00:00 | 2,869 | false | \n\n# \u2B06\uFE0FPlease Upvote If You Like the Solution :)\n\n# Approach\n1. We know that we need to complement. For that we need to change `0` to `1` and `1` to `0`.\n\n2. We need to think, what can we us... | 38 | 0 | ['Bit Manipulation', 'C', 'Bitmask', 'C++'] | 4 |
complement-of-base-10-integer | C++ 0ms solution using bitwise operation | c-0ms-solution-using-bitwise-operation-b-eklw | The idea is to find the bit length of N, construct a string of 1\'s with the same length, and XOR with N.\n\nFor example, 5 in binary is 101. Notice that 101 ^ | vanesschanppi | NORMAL | 2020-05-05T03:54:47.577522+00:00 | 2020-05-10T02:07:09.681309+00:00 | 2,128 | false | The idea is to find the bit length of N, construct a string of 1\'s with the same length, and XOR with N.\n\nFor example, 5 in binary is 101. Notice that 101 ^ 111 = 010 (2 in decimal).\n\n int bitwiseComplement(int N) {\n int comp = 1;\n while (comp < N) \n comp = (comp << 1) | 1;\n ... | 35 | 1 | [] | 5 |
complement-of-base-10-integer | [Python] Oneliner explained | python-oneliner-explained-by-dbabichev-vlvp | What we actually need to find in this problem is length of our number in bits: if we have 10 = 1010, then complementary is 5 = 101. Note, that 5 + 10 = 15 = 2^4 | dbabichev | NORMAL | 2020-10-05T09:12:35.316946+00:00 | 2020-10-05T09:12:35.316990+00:00 | 1,624 | false | What we actually need to find in this problem is length of our number in bits: if we have `10 = 1010`, then complementary is `5 = 101`. Note, that `5 + 10 = 15 = 2^4 - 1`. So, let us just find length of our number in bits and subtract `N-1`.\n\n**Complexity** time complexity is `O(log N)` to find its length; space comp... | 29 | 4 | [] | 2 |
complement-of-base-10-integer | [JAVA] Detailed Explanation of Intution| BIT MASKING|BIT FLIP | 5 Approach | java-detailed-explanation-of-intution-bi-a9ir | Intution: Since we have to find the complement of a given decimal number in binary form, we will use the complement property which is N + Compliment(N) = 111... | abhi9720 | NORMAL | 2022-01-04T03:39:16.146367+00:00 | 2022-01-04T10:13:18.104859+00:00 | 942 | false | *Intution:* Since we have to find the complement of a given decimal number in binary form, we will use the complement property which is N + Compliment(N) = 111....111.\nFoe Example : \n* N = 5 => N = 101 , Compliment(N) = 010 => 101 + 010 = 111\n* N = 8 => N = 1000 , Compliment(N) = 0111 => 1000 + 0111 = 1111\n* N = 17... | 21 | 8 | ['Bit Manipulation', 'Bitmask', 'Java'] | 1 |
complement-of-base-10-integer | Java 0ms 32mb... beats 100% | java-0ms-32mb-beats-100-by-msadler-66mi | Intuition:\nWe want to XOR N\'s binary with an array of 1\'s of the same length.\nApproach:\nFind out how long N is (via while loop.... 2^y=N).\nThen we subtrac | msadler | NORMAL | 2019-03-19T20:08:28.372736+00:00 | 2019-05-07T23:51:13.870383+00:00 | 2,507 | false | **Intuition:**\nWe want to XOR N\'s binary with an array of 1\'s of the same length.\n**Approach:**\nFind out how long N is (via while loop.... 2^y=N).\nThen we subtract 1 from our number, and we will get an array of 1\'s in binary.\n(ie. if x=2^8, then x-1 in binary is "1111 1111").\n\n\n\n```\nclass Solution {\n p... | 18 | 1 | [] | 6 |
complement-of-base-10-integer | Python 4 lines: faster than 99%, memory less than 100% | python-4-lines-faster-than-99-memory-les-hn24 | \nclass Solution:\n def bitwiseComplement(self, N: int) -> int:\n P = 2\n while P <= N:\n P *= 2\n return P - 1 - N\n\nIf P i | chenyian | NORMAL | 2019-05-14T01:58:29.385585+00:00 | 2020-06-21T02:28:27.028516+00:00 | 1,817 | false | ```\nclass Solution:\n def bitwiseComplement(self, N: int) -> int:\n P = 2\n while P <= N:\n P *= 2\n return P - 1 - N\n```\nIf P is the smallest power of 2 larger than N, then N and its binary complement M satisfies N+M=P-1. | 17 | 0 | [] | 5 |
complement-of-base-10-integer | C++ | 100% faster | Beginner friendly | Simple Math | c-100-faster-beginner-friendly-simple-ma-ft8z | \nint bitwiseComplement(int n) {\n int i;\n for(i=0;i<=n;)\n {\n i=(i*2)+1;\n if(n<=i)\n break;\n | shyamal122 | NORMAL | 2022-01-04T11:04:10.846331+00:00 | 2022-01-04T11:04:10.846371+00:00 | 759 | false | ```\nint bitwiseComplement(int n) {\n int i;\n for(i=0;i<=n;)\n {\n i=(i*2)+1;\n if(n<=i)\n break;\n }\n return i-n; \n }\n```\t\n\n\n**If you have some doubts feel free to ask me.**\nIt\'s my first post on leetcode.If you like it please upvo... | 13 | 1 | ['Math', 'C'] | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.