{"id":19584380,"url":"https://github.com/debhere/leetcode-solutions","last_synced_at":"2026-02-26T02:03:16.882Z","repository":{"id":172964295,"uuid":"648480815","full_name":"debhere/LeetCode-Solutions","owner":"debhere","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-22T12:47:11.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-22T12:58:32.854Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"SQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/debhere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-02T04:28:44.000Z","updated_at":"2024-04-26T18:34:05.295Z","dependencies_parsed_at":null,"dependency_job_id":"5a775f55-5a62-49c0-aa37-dcc2eee6a5b3","html_url":"https://github.com/debhere/LeetCode-Solutions","commit_stats":null,"previous_names":["debhere/leetcode-solutions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debhere%2FLeetCode-Solutions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debhere%2FLeetCode-Solutions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debhere%2FLeetCode-Solutions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debhere%2FLeetCode-Solutions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/debhere","download_url":"https://codeload.github.com/debhere/LeetCode-Solutions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240858402,"owners_count":19868994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T07:47:59.890Z","updated_at":"2026-02-26T02:03:16.803Z","avatar_url":"https://github.com/debhere.png","language":"SQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"\r\n# This repository contains LeetCode solutions and certain learnings on the way forward...!!!\r\n\r\n\r\n## Learnings\r\n\r\n### SQL\r\n\r\n1. Add below two lines in the gitattributes to include SQL in the language statistics.\r\n\r\n\t*.sql linguist-language=sql\r\n\t\r\n\t*.sql linguist-detectable=true\r\n\r\n2. auto_increment in MySQL is similar to Identity() in SQL-Server.\r\n3. Constraint naming inline to column declaration is not permissible in MySQL\r\n\r\n```\r\nCreate Table Products\r\n(product_id int Constraint PK_Products Primary Key Identity(1,1),\r\nproduct_name varchar(100),\r\nproduct_category varchar(50))\r\n```\r\nThe above is a valid query in SQL-Server whereas in MySQL it becomes\r\n\r\n```\r\nCreate Table Products\r\n(product_id int Primary Key auto_increment,\r\nproduct_name varchar(100),\r\nproduct_category varchar(50));\r\n```\r\n\r\n4. Foreign key declaration for MySQL can only be done at the end of table declaration\r\n\r\n```\r\nCreate Table Orders\r\n(product_id int ,\r\norder_date date,\r\nunit int,\r\nFOREIGN KEY (product_id) REFERENCES Products(product_id));\r\n```\r\n\r\n5. While inserting values into another table with foreign key constraints, MySQL throws an error until setting the below line.\r\n\r\n```\r\nSET FOREIGN_KEY_CHECKS=0;\r\n```\r\n\r\n6. Even for auto_increment, need to mention the column names the values being inserted\r\n\r\n```\r\ninsert into Products (product_name, product_category) values\r\n('Leetcode Solutions', 'Book'),\r\n('Jewels of Stringology', 'Book'),\r\n('HP', 'Laptop'),\r\n('Lenovo', 'Laptop'),\r\n('Leetcode Kit', 'T-shirt');\r\n```\r\n\r\n7. Wildcard characters like [], -, ^ does not work in MySQL. Instead one can use 'regexp' keyword for a pattern matching in the query in MySQL. Here is an example\r\n\r\n```\r\nselect * from Users\r\nwhere mail regexp '^[a-zA-Z][a-zA-Z0-9_.-]*@leetcode[.]com$';\r\n```\r\n\r\n8. Similar to ISNULL(expr, value) in SQL-Server, MySQL has IFNULL(expr, value) function that can return a specific value if the expression is NULL.\r\n\r\n\r\n9. Display selected values as commas seperated string using function STRING_AGG() in SQL-Server and GROUP_CONCAT() in MySQL.\r\n\r\n```\r\nselect sell_date, count(product) num_sold, STRING_AGG(product, ',') as products\r\nfrom (select distinct * from Activities) T\r\ngroup by sell_date\r\n```\r\n\r\n```\r\nselect sell_date, count(distinct product) num_sold, group_concat(distinct product order by product asc) products\r\nfrom Activities\r\ngroup by sell_date\r\n```\r\n\r\n\r\n10. DATEDIFF works both for SQL-Server and MySQL but with a small difference in thr syntax. In SQL-Server, we need to mention the interval.\r\n\r\n```bash\r\n\r\nDATEDIFF(interval, date1, date2) returns number of days when interval = 'DAY' -- SQL server \r\nDATEDIFF(date1, date2) returns number of days -- MySQL\r\n```\r\n\r\n\r\n\r\n### Python\r\n\r\n1. say nums[] is an existing list. Now, nums[:] means creating a new list as nums but it is a not the same object but a different one.\r\n2. O(logn) is common complexity, where there is a concept of halving or say to perform some action on next element based on some conditions.\r\n3. int(n, 2) base 2 to convert to integer from binary.\r\n4. := is a valid operator that allows assignment of variable within expressions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebhere%2Fleetcode-solutions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdebhere%2Fleetcode-solutions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebhere%2Fleetcode-solutions/lists"}