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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
finding-mk-average | Use 3 TreeMap + Queue | use-3-treemap-queue-by-ruinan-dyz5 | Intuition\n1. Tried 3 PQ and each time when calculateMKAverage, traverse small and large PQ to calculate the sum for them == LTE\n2. Tried 3 TreeMap, but did no | ruinan | NORMAL | 2024-09-29T23:30:49.442548+00:00 | 2024-09-29T23:30:49.442584+00:00 | 12 | false | # Intuition\n1. Tried 3 PQ and each time when calculateMKAverage, traverse small and large PQ to calculate the sum for them == LTE\n2. Tried 3 TreeMap, but did not use the balance method, rather than, apply moveToSmall, moveToLarge to recursively balance the Map == Stack Overflow\n\n# Approach\nMaintain 3 TreeMap, firs... | 0 | 0 | ['Java'] | 0 |
finding-mk-average | ✅ Production ready c++ code | production-ready-c-code-by-rohanprakash-xlpj | Intuition\nThe problem is to compute the moving average of a data stream while excluding the smallest and largest elements to prevent extreme values from skewin | RohanPrakash | NORMAL | 2024-09-28T05:22:13.426310+00:00 | 2024-09-28T05:22:13.426333+00:00 | 34 | false | # Intuition\nThe problem is to compute the moving average of a data stream while excluding the smallest and largest elements to prevent extreme values from skewing the results. This requires maintaining a dynamic set of the most recent data points such that we can efficiently calculate the average of the middle values ... | 0 | 0 | ['C++'] | 0 |
add-to-array-form-of-integer | 🔥🚀Simplest Solution🚀||🔥Full Explanation||🔥C++🔥|| Python3 || Java | simplest-solutionfull-explanationc-pytho-4pno | Consider\uD83D\uDC4D\n\n Please Upvote If You Find It Helpful\n\n# Intuition\nWe are taking k as carry.\nWe start from the last or lowest dig | naman_ag | NORMAL | 2023-02-15T01:49:33.396974+00:00 | 2023-02-15T02:27:32.758241+00:00 | 26,764 | false | # Consider\uD83D\uDC4D\n```\n Please Upvote If You Find It Helpful\n```\n# Intuition\nWe are taking `k` as carry.\nWe start from the last or lowest digit in array `num` add `k`.\nThen **update** `k` and move untill the highest digit.\nAfter traversing array if carry is **>** `0` then we add it to be... | 357 | 1 | ['Array', 'Python', 'C++', 'Java', 'Python3'] | 21 |
add-to-array-form-of-integer | [Java/C++/Python] Take K itself as a Carry | javacpython-take-k-itself-as-a-carry-by-g9mh0 | Explanation\nTake K as a carry.\nAdd it to the lowest digit,\nUpdate carry K,\nand keep going to higher digit.\n\n\n## Complexity\nInsert will take O(1) time or | lee215 | NORMAL | 2019-02-10T04:04:03.694782+00:00 | 2020-08-18T03:39:15.820573+00:00 | 32,009 | false | ## **Explanation**\nTake `K` as a carry.\nAdd it to the lowest digit,\nUpdate carry `K`,\nand keep going to higher digit.\n<br>\n\n## **Complexity**\nInsert will take `O(1)` time or `O(N)` time on shifting, depending on the data stucture.\nBut in this problem `K` is at most 5 digit so this is restricted.\nSo this part ... | 337 | 6 | [] | 49 |
add-to-array-form-of-integer | ✅ [JAVA] : Simple | O(max(n, logk)) | No Reverse | Efficient | Explained | java-simple-omaxn-logk-no-reverse-effici-cnt3 | Please UPVOTE if you find this post useful :)\n\nRefer to the following github repsitory for more leetcode solutions\nhttps://github.com/Akshaya-Amar/LeetCodeSo | akshayaamar05 | NORMAL | 2021-06-21T11:03:43.650557+00:00 | 2022-02-04T11:24:43.798414+00:00 | 7,987 | false | # **Please UPVOTE if you find this post useful :)**\n\n<u><strong>Refer to the following github repsitory for more leetcode solutions<strong></u>\nhttps://github.com/Akshaya-Amar/LeetCodeSolutions\n\n* <u>**COMPLEXITY**</u>\n\t* **Time: O(max(n, log<sub>10</sub>(k)))**, where **n** is the **length of the array** and **... | 111 | 2 | ['Java'] | 9 |
add-to-array-form-of-integer | ✅ Java | Easy | Two Approaches | Math | 100% faster | java-easy-two-approaches-math-100-faster-o6z3 | Approach 1\n\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n LinkedList<Integer> res=new LinkedList<>();\n int ca | kalinga | NORMAL | 2023-02-15T04:21:22.751854+00:00 | 2023-02-15T04:21:22.751889+00:00 | 9,300 | false | **Approach 1**\n```\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n LinkedList<Integer> res=new LinkedList<>();\n int carry=0;\n int i=0;\n\t\t/*We always start computing from array\'s last element and k\'s last digit and will \n\t\tcompute sum and carry. We will it... | 90 | 0 | ['Array', 'Linked List', 'Math', 'Java'] | 5 |
add-to-array-form-of-integer | C++| FAST AND EFFICIENT | with explanation | c-fast-and-efficient-with-explanation-by-h94b | Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome\n\nContinuin | aarindey | NORMAL | 2021-06-14T20:13:20.320348+00:00 | 2023-02-16T07:49:14.725472+00:00 | 6,691 | false | **Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome**\n\nContinuing the example of 123 + 912, we start with [1, 2, 3+912]. Then we perform the addition 3+912, leaving 915. The 5 stays as the digit, while we \'carry\' 910 i... | 78 | 1 | ['C'] | 6 |
add-to-array-form-of-integer | C++✅✅ | Faster🧭 than 95%🔥 | NO SHORTCUT MEHTHOD❗❗❗ | Self Explanatory Code | | c-faster-than-95-no-shortcut-mehthod-sel-7s00 | Code\n\n# Please Do Upvote!!!!\n##### Connect with me on Linkedin -> https://www.linkedin.com/in/md-kamran-55b98521a/\n\n\n\nclass Solution {\npublic:\n\n ve | mr_kamran | NORMAL | 2023-02-15T02:27:30.550184+00:00 | 2023-02-15T02:48:22.590804+00:00 | 13,068 | false | # Code\n\n# Please Do Upvote!!!!\n##### Connect with me on Linkedin -> https://www.linkedin.com/in/md-kamran-55b98521a/\n\n```\n\nclass Solution {\npublic:\n\n vector<int> addToArrayForm(vector<int>& num, int k) {\n \n int carry = 0;\n int j = num.size() - 1;\n\n while(j >= 0)\n {\... | 69 | 1 | ['C++'] | 8 |
add-to-array-form-of-integer | Day 46 || C++ || Easiest Beginner Friendly Sol || O(max(N, log K)) time and O(max(N, log K)) space | day-46-c-easiest-beginner-friendly-sol-o-sfm1 | Intuition of this Problem:\n Describe your first thoughts on how to solve this problem. \nNOTE - PLEASE READ APPROACH FIRST THEN SEE THE CODE. YOU WILL DEFINITE | singhabhinash | NORMAL | 2023-02-15T01:02:04.571471+00:00 | 2023-02-15T01:02:04.571511+00:00 | 6,624 | false | # Intuition of this Problem:\n<!-- Describe your first thoughts on how to solve this problem. -->\n**NOTE - PLEASE READ APPROACH FIRST THEN SEE THE CODE. YOU WILL DEFINITELY UNDERSTAND THE CODE LINE BY LINE AFTER SEEING THE APPROACH.**\n\n# Approach for this Problem:\n1. Initialize an empty vector "ans" to store the fi... | 35 | 1 | ['Array', 'Math', 'C++', 'Java', 'Python3'] | 4 |
add-to-array-form-of-integer | C++ Well Commented Solution [With Explanation] [100%] | c-well-commented-solution-with-explanati-t6kh | \n/* An important observation ---\n1) num%10 gives us the last digit of a number\n2) num = num/10 cuts off the last digit of the number \n3) numVector.back() gi | just__a__visitor | NORMAL | 2019-02-10T04:36:32.493440+00:00 | 2019-02-10T04:36:32.493485+00:00 | 3,722 | false | ```\n/* An important observation ---\n1) num%10 gives us the last digit of a number\n2) num = num/10 cuts off the last digit of the number \n3) numVector.back() gives us the last digit of the number in vector form\n4) numVector.pop_back() cuts off the last digit of the number in vector form\n5) The extra space required... | 35 | 5 | [] | 6 |
add-to-array-form-of-integer | [Java/Python 3] 6 liner w/ comment and analysis | javapython-3-6-liner-w-comment-and-analy-1jev | Note:\n\nI read several other java solutions, and found ArrayList.add(0, K % 10) was used, and it is not O(1) but O(n) instead. \n\nLinkedList.add(0, i) or offe | rock | NORMAL | 2019-02-10T04:59:06.218448+00:00 | 2020-07-15T15:29:07.434140+00:00 | 5,039 | false | # **Note:**\n\nI read several other java solutions, and found `ArrayList.add(0, K % 10)` was used, and it is not `O(1)` but `O(n)` instead. \n\n`LinkedList.add(0, i)` or `offerFirst(i)` is `O(1)`.\n\nCorrect me if I am wrong.\n\n```java\n public List<Integer> addToArrayForm(int[] A, int K) {\n LinkedList<Inte... | 28 | 4 | [] | 10 |
add-to-array-form-of-integer | Java Solution (optimal and simple) | java-solution-optimal-and-simple-by-simr-l29w | \'\'\'\nclass Solution {\n public List addToArrayForm(int[] num, int k) {\n \n final LinkedList result = new LinkedList<>();\n int len = | simrananand | NORMAL | 2022-02-17T00:36:50.338685+00:00 | 2022-02-17T00:36:50.338717+00:00 | 2,740 | false | \'\'\'\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n \n final LinkedList<Integer> result = new LinkedList<>();\n int len = num.length - 1;\n \n while(len >= 0 || k != 0){\n \n if(len >= 0){\n k += num[len];\n\t\t\... | 25 | 1 | ['Linked List', 'Java'] | 2 |
add-to-array-form-of-integer | (C++) [Very Easy To Understand] | c-very-easy-to-understand-by-not_a_cp_co-z6sw | \nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& A, int K) {\n vector<int> ans;\n int carry = 0, i = A.size()-1;\n | not_a_cp_coder | NORMAL | 2020-07-19T10:54:59.285121+00:00 | 2020-07-19T10:54:59.285170+00:00 | 3,536 | false | ```\nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& A, int K) {\n vector<int> ans;\n int carry = 0, i = A.size()-1;\n while(i>=0 || carry > 0 || K!=0){\n if(K!=0){\n carry += K%10;\n K = K/10;\n }\n if(i>=0){\n ... | 23 | 1 | ['Math', 'C', 'C++'] | 3 |
add-to-array-form-of-integer | JavaScript Solution with Full Explanation | javascript-solution-with-full-explanatio-vf7o | Please upvote if you find the solution helpful.\n\n\nvar addToArrayForm = function(num, k) {\n\n let i = num.length - 1;\n let res = [];\n while(i >= 0 | SOURADIP22 | NORMAL | 2021-09-05T13:51:17.939588+00:00 | 2021-09-05T13:51:17.939627+00:00 | 1,853 | false | *Please upvote if you find the solution helpful.*\n\n```\nvar addToArrayForm = function(num, k) {\n\n let i = num.length - 1;\n let res = [];\n while(i >= 0 || k >0 ){\n\t\t//this is the general check : taking the last elemnt and adding it with the k value then take the carry(if any to the next iteration) \n ... | 20 | 0 | ['JavaScript'] | 3 |
add-to-array-form-of-integer | [Python3] Improving the Leetcode Solution and Avoiding the Use of 'str', 'int' and 'map' | python3-improving-the-leetcode-solution-ksmap | Notes:\n- Leetcode provided a simple solution, but it is not efficient. K has 5 digits at most, but A can have 10000 elements. This means that the summation mig | dr_sean | NORMAL | 2019-11-26T01:24:45.238618+00:00 | 2019-11-27T19:37:56.419583+00:00 | 3,681 | false | # Notes:\n- Leetcode provided a simple [solution](https://leetcode.com/problems/add-to-array-form-of-integer/solution/), but it is not efficient. K has 5 digits at most, but A can have 10000 elements. This means that the summation might finish after 5 iterations, but the loop will continue for 10000 times! I added a co... | 19 | 1 | ['Python', 'Python3'] | 2 |
add-to-array-form-of-integer | Java easy to understand solution | java-easy-to-understand-solution-by-daij-abzg | \nclass Solution {\n public List<Integer> addToArrayForm(int[] A, int K) {\n LinkedList<Integer> res = new LinkedList<>();\n int carry = 0;\n | daijidj | NORMAL | 2019-02-12T23:38:53.903503+00:00 | 2019-02-12T23:38:53.903547+00:00 | 2,709 | false | ```\nclass Solution {\n public List<Integer> addToArrayForm(int[] A, int K) {\n LinkedList<Integer> res = new LinkedList<>();\n int carry = 0;\n int index = A.length - 1;\n while(K > 0 || index >= 0){\n int curK = K % 10;\n int curA = index >= 0 ? A[index]: 0;\n ... | 19 | 2 | [] | 2 |
add-to-array-form-of-integer | 4ms (Beats 90.00%)🔥🔥|| Full Explanation✅|| Breadth First Search✅|| C++|| Java|| Python3 | 4ms-beats-9000-full-explanation-breadth-6711j | Intuition :\n- Here we have to add a non-negative integer k to an array of non-negative integers num, where each element in num is between 0 and 9 (inclusive), | N7_BLACKHAT | NORMAL | 2023-02-15T05:18:05.392845+00:00 | 2023-02-15T05:18:05.392899+00:00 | 1,606 | false | # Intuition :\n- Here we have to add a non-negative integer k to an array of non-negative integers num, where each element in num is between 0 and 9 (inclusive), and returning the result as a list of integers.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Explanation to Approach :\n- First, ... | 15 | 0 | ['Math', 'Python', 'C++', 'Java', 'Python3'] | 1 |
add-to-array-form-of-integer | JAVA simple solution Array List Beginner friendly | java-simple-solution-array-list-beginner-16is | Runtime: 42 ms, faster than 19.81% of Java online submissions for Add to Array-Form of Integer.\nMemory Usage: 40.4 MB, less than 54.92% of Java online submissi | gautammali_740 | NORMAL | 2021-08-24T06:52:52.892458+00:00 | 2021-08-24T06:52:52.892502+00:00 | 1,822 | false | **Runtime: 42 ms, faster than 19.81% of Java online submissions for Add to Array-Form of Integer.\nMemory Usage: 40.4 MB, less than 54.92% of Java online submissions for Add to Array-Form of Integer.**\n\n\n```\nList<Integer> ans=new ArrayList<>();\n \n for(int i=num.length-1;i>=0;i--){\n \n ... | 12 | 0 | ['Java'] | 1 |
add-to-array-form-of-integer | Python - One Liner - Better than 88% | python-one-liner-better-than-88-by-mb557-hka3 | Approach:\n1. Convert the list of integers into a single number using join()\n2. Explicitly convert the new string into int and add it with K.\n3. Convert the s | mb557x | NORMAL | 2020-07-10T05:41:26.718236+00:00 | 2020-07-10T05:41:26.718276+00:00 | 1,206 | false | Approach:\n1. Convert the list of integers into a single number using ```join()```\n2. Explicitly convert the new string into int and add it with ```K```.\n3. Convert the sum into string and return it as a list using ```list()```.\n\n```\nclass Solution:\n def addToArrayForm(self, A: List[int], K: int) -> List[int]:... | 12 | 2 | ['Python3'] | 4 |
add-to-array-form-of-integer | [JavaScript] Clean and fast solution with explanation.(No reverse) | javascript-clean-and-fast-solution-with-gjnza | js\nvar addToArrayForm = function(A, K) {\n let flag = A.length - 1\n while(K) {\n if(flag < 0) {\n A.unshift(K % 10)\n } else {\ | ray7102ray7102 | NORMAL | 2019-03-19T11:19:10.321240+00:00 | 2019-03-19T11:19:10.321283+00:00 | 1,918 | false | ```js\nvar addToArrayForm = function(A, K) {\n let flag = A.length - 1\n while(K) {\n if(flag < 0) {\n A.unshift(K % 10)\n } else {\n K += A[flag]\n A[flag--] = K % 10\n }\n K = Math.floor(K / 10)\n }\n return A\n}\n```\nExplanation:\n1. Take `K` ... | 12 | 0 | ['JavaScript'] | 2 |
add-to-array-form-of-integer | Screencast of LeetCode Weekly Contest 123 | screencast-of-leetcode-weekly-contest-12-3k0w | https://www.youtube.com/watch?v=50jJcFYaskQ | cuiaoxiang | NORMAL | 2019-02-10T04:08:04.588689+00:00 | 2019-02-10T04:08:04.588760+00:00 | 1,468 | false | https://www.youtube.com/watch?v=50jJcFYaskQ | 12 | 2 | [] | 4 |
add-to-array-form-of-integer | ✅Java | Easy Solution With Detailed Explanation | java-easy-solution-with-detailed-explana-2xkn | Approach\n Describe your approach to solving the problem. \n- We approach this question just like we add two numbers given that you can add only one-one digits | olifarhaan | NORMAL | 2023-02-15T03:55:29.701630+00:00 | 2023-02-15T13:34:36.262708+00:00 | 2,636 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n- We approach this question just like we add two numbers given that you can add only one-one digits at a time.\n- We start iterating to the array from the last of it, & also from the last of k as well.\n- At each iteration, we keep adding the `carry` ... | 11 | 0 | ['Array', 'Math', 'Java'] | 2 |
add-to-array-form-of-integer | ✅ For N base characters and beyond | 🔰 O(n) Time and O(n) space❗️ | for-n-base-characters-and-beyond-on-time-bacz | Intuition\nThis problem is similar to problem: 67. Add Binary. You should try and solve that problem first. If you are still confused, see the below solution.\n | hridoy100 | NORMAL | 2023-02-15T05:43:01.380646+00:00 | 2023-02-15T06:29:13.319761+00:00 | 626 | false | # Intuition\nThis problem is similar to problem: [67. Add Binary](https://leetcode.com/problems/add-binary/). You should try and solve that problem first. If you are still confused, see the below solution.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nMy solution to [67. Add Binary](https://le... | 10 | 0 | ['Java'] | 1 |
add-to-array-form-of-integer | 📌📌 C++ || Math || Two Pointer || Faster || Easy To Understand | c-math-two-pointer-faster-easy-to-unders-3s4m | Math\n\n Time Complexity :- O(N)\n\n Space Complexity :- O(Constant)\n\n\nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& num, int k) {\n | __KR_SHANU_IITG | NORMAL | 2023-02-15T03:52:25.143687+00:00 | 2023-02-15T03:52:25.143718+00:00 | 3,001 | false | * ***Math***\n\n* ***Time Complexity :- O(N)***\n\n* ***Space Complexity :- O(Constant)***\n\n```\nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& num, int k) {\n \n int n = num.size();\n \n // convert the k into string\n \n string str = to_string(k);\n ... | 10 | 0 | ['Math', 'C', 'C++'] | 1 |
add-to-array-form-of-integer | [Java] 3 different approach || 55ms to 4ms runtime | java-3-different-approach-55ms-to-4ms-ru-ca3p | Hii,\nIntuition :\n\nBASIC IDEA\n1. Basic Idea behind this implementation is to add the num array element one by one with the k\neg:\nnum[] = {1, 2, 3} and k = | kartik04 | NORMAL | 2022-07-11T01:11:01.419597+00:00 | 2022-07-12T21:49:38.572623+00:00 | 999 | false | Hii,\n**Intuition :**\n\nBASIC IDEA\n1. Basic Idea behind this implementation is to add the num array element one by one with the k\neg:\nnum[] = {1, 2, 3} and k = 45;\n\n* \t1st Iteration:\nk += num[len--] --> k = k + num[2] --> k = 45 + 3 --> k = 48\nlist.addFirst(k % 10) --> list.addFirst(48 % 10) --> list.addFirst... | 10 | 0 | ['Java'] | 1 |
add-to-array-form-of-integer | Simple Python | simple-python-by-jlepere2-oyvb | \nclass Solution:\n def addToArrayForm(self, A: \'List[int]\', K: \'int\') -> \'List[int]\':\n A[-1] += K\n i = len(A) - 1\n while i > 0 | jlepere2 | NORMAL | 2019-02-10T04:03:26.087533+00:00 | 2019-02-10T04:03:26.087602+00:00 | 1,739 | false | ```\nclass Solution:\n def addToArrayForm(self, A: \'List[int]\', K: \'int\') -> \'List[int]\':\n A[-1] += K\n i = len(A) - 1\n while i > 0 and A[i] > 9:\n A[i-1] += A[i] // 10\n A[i] = A[i] % 10\n i -= 1\n while A[0] > 9:\n A = [A[0] // 10] + A... | 9 | 1 | [] | 1 |
add-to-array-form-of-integer | Easy Javascript solution | easy-javascript-solution-by-kamalbhera-vwjh | \n# 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 | kamalbhera | NORMAL | 2023-02-15T03:19:04.100660+00:00 | 2023-02-15T09:00:47.546982+00:00 | 2,847 | false | \n# 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```\n/**\n * @param {number[]} num\n * @param {number} k\n * @return {number[]}\n */\nvar addToArrayForm = function(num, k... | 8 | 0 | ['JavaScript'] | 6 |
add-to-array-form-of-integer | 📌📌Python3 || ⚡268 ms, faster than 96.60% of Python3 | python3-268-ms-faster-than-9660-of-pytho-0tq9 | \n\nclass Solution:\n def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n if not num:\n return [int(d) for d in str(k)]\n | harshithdshetty | NORMAL | 2023-02-15T02:17:03.578417+00:00 | 2023-02-15T02:17:03.578460+00:00 | 3,153 | false | \n```\nclass Solution:\n def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n if not num:\n return [int(d) for d in str(k)]\n carry = 0\n res = []\n for i i... | 8 | 0 | ['Python', 'Python3'] | 1 |
add-to-array-form-of-integer | C# | c-by-leonenko-4xou | \npublic IList<int> AddToArrayForm(int[] A, int K) {\n var i = A.Length - 1;\n var result = new List<int>();\n while(i >= 0 || K > 0) {\n K += ( | leonenko | NORMAL | 2019-02-10T04:20:18.103368+00:00 | 2019-02-10T04:20:18.103426+00:00 | 510 | false | ```\npublic IList<int> AddToArrayForm(int[] A, int K) {\n var i = A.Length - 1;\n var result = new List<int>();\n while(i >= 0 || K > 0) {\n K += (i >= 0 ? A[i--] : 0);\n result.Add((K % 10));\n K /= 10;\n }\n result.Reverse();\n return result;\n}\n``` | 8 | 2 | [] | 0 |
add-to-array-form-of-integer | JAVA EASY Solution WIth EXPLANATION | java-easy-solution-with-explanation-by-d-nhyn | JAVA SOLUTION @DeepakKumar\n# In Case of Any Doubt Feel Free to ASK...\n\n\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n // | Deepak2002 | NORMAL | 2021-11-02T13:08:26.479529+00:00 | 2021-11-02T13:08:26.479668+00:00 | 811 | false | # JAVA SOLUTION @DeepakKumar\n# In Case of Any Doubt Feel Free to ASK...\n\n```\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n // Create A List\n List<Integer> list = new ArrayList<>();\n // Start from Last index of num Array\n /*\n INDEX ... | 7 | 0 | ['Java'] | 0 |
add-to-array-form-of-integer | A Simple Java Solution | a-simple-java-solution-by-praneeth003-o1zn | \n\n\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n ArrayList<Integer> arr = new ArrayList<Integer>();\n for (in | Praneeth003 | NORMAL | 2021-08-27T15:07:15.006451+00:00 | 2021-08-27T15:07:15.006502+00:00 | 1,018 | false | \n\n```\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n ArrayList<Integer> arr = new ArrayList<Integer>();\n for (int i = num.length - 1; i >= 0 ; i--) {\n arr.add((num[i] + k) % 10);\n k = (num[i] + k) / 10;\n }\n while (k>0){\n ... | 7 | 1 | ['Java'] | 1 |
add-to-array-form-of-integer | Python3 One Line | python3-one-line-by-jimmyyentran-zdd1 | A = [1,2,0,0], K = 34\n[1,2,0,0] -> "1200" -> 1200 -> add K -> 1234 -> "1234" -> [1,2,3,4]\npython\nclass Solution:\n def addToArrayForm(self, A: \'List[int] | jimmyyentran | NORMAL | 2019-02-10T04:11:14.078698+00:00 | 2019-02-10T04:11:14.078763+00:00 | 787 | false | A = [1,2,0,0], K = 34\n[1,2,0,0] -> "1200" -> 1200 -> add K -> 1234 -> "1234" -> [1,2,3,4]\n```python\nclass Solution:\n def addToArrayForm(self, A: \'List[int]\', K: \'int\') -> \'List[int]\':\n return [int(s) for s in str(int(\'\'.join(str(x) for x in A)) + K)]\n``` | 7 | 1 | [] | 1 |
add-to-array-form-of-integer | ✔C++|Very Easy | Beats 100% | O(n) |✔ | cvery-easy-beats-100-on-by-xahoor72-uddq | Intuition\n Describe your first thoughts on how to solve this problem. \nSimply just transform k into an array for easy traversal then just take care of carry a | Xahoor72 | NORMAL | 2023-02-15T06:07:14.875523+00:00 | 2023-02-15T06:32:49.700727+00:00 | 4,321 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimply just transform k into an array for easy traversal then just take care of carry and take the sum of nums vector and kth vector .\n- We can avoid using the vector for k by just taking directly elements from k .\n- Below are given the... | 6 | 0 | ['Array', 'Math', 'Number Theory', 'C++'] | 0 |
add-to-array-form-of-integer | Beginner friendly [JavaScript/Python] solution | beginner-friendly-javascriptpython-solut-myx6 | \njavascript []\nvar addToArrayForm = function(num, k) {\n let res = [], i=num.length\n while(i-- > 0 || k){\n if(i >= 0) k += num[i];\n re | HimanshuBhoir | NORMAL | 2022-08-12T14:32:05.307111+00:00 | 2022-12-19T12:57:40.562113+00:00 | 1,284 | false | \n```javascript []\nvar addToArrayForm = function(num, k) {\n let res = [], i=num.length\n while(i-- > 0 || k){\n if(i >= 0) k += num[i];\n res.unshift(k%10)\n k = Math.floor(k/10)\n }\n return res\n};\n```\n\n``` python []\nclass Solution(object):\n def addToArrayForm(self, num, k)... | 6 | 0 | ['Python', 'JavaScript'] | 0 |
add-to-array-form-of-integer | C++: Faster than 91% of C++ | c-faster-than-91-of-c-by-vmk1802-tqb2 | \nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int> &A, int K)\n {\n int i, size = A.size();\n\n for (i = size - 1; i >= 0 | vmk1802 | NORMAL | 2020-12-01T15:07:46.165232+00:00 | 2020-12-22T12:13:42.988707+00:00 | 1,231 | false | ```\nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int> &A, int K)\n {\n int i, size = A.size();\n\n for (i = size - 1; i >= 0 && K != 0; i--)\n {\n K = K + A[i];\n A[i] = K % 10;\n K = K / 10;\n }\n while (K != 0)\n {\n ... | 6 | 0 | ['C', 'C++'] | 0 |
add-to-array-form-of-integer | C++ Reverse | c-reverse-by-votrubac-b7eb | Reverse the string first to simplify things. Then add numbers left to rigth, and mind the overflow.\n\nIf needed, add an extra character to the end of the strin | votrubac | NORMAL | 2019-02-10T04:07:58.463777+00:00 | 2019-02-10T04:07:58.463817+00:00 | 934 | false | Reverse the string first to simplify things. Then add numbers left to rigth, and mind the overflow.\n\nIf needed, add an extra character to the end of the string. Since the string is reversed, adding a character does not require shifting the whole string.\n\nIn the end, reverse the string back.\n```\nvector<int> addToA... | 6 | 2 | [] | 0 |
add-to-array-form-of-integer | JAVA || Beats 98% | java-beats-98-by-tamannannaaaa-xn1m | \n# Code\njava []\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n List<Integer> result=new ArrayList<>();\n int n | tamannannaaaa | NORMAL | 2024-09-05T20:52:12.323119+00:00 | 2024-09-05T20:52:12.323148+00:00 | 369 | false | \n# Code\n```java []\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n List<Integer> result=new ArrayList<>();\n int n=num.length;\n\n for(int i=n-1;i>=0;i--){\n k+=num[i];\n result.add(k%10); \n k/=10; \n }\n while(k>0){... | 5 | 0 | ['Java'] | 0 |
add-to-array-form-of-integer | [Python] - Clean & Simple Solution | python-clean-simple-solution-by-yash_vis-5flc | For Time Complexity we can say O(n),\nand for space O(1). \n\n# Code\n\nclass Solution:\n def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n | yash_visavadia | NORMAL | 2023-02-15T18:44:28.578027+00:00 | 2023-02-15T18:48:06.972077+00:00 | 562 | false | - For Time Complexity we can say O(n),\nand for space O(1). \n\n# Code\n```\nclass Solution:\n def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n n = 0\n for i in num:\n n = n * 10 + i\n \n n = n + k\n num = []\n\n while n != 0:\n num.appe... | 5 | 0 | ['Python3'] | 0 |
add-to-array-form-of-integer | [Java] array solution like in school | java-array-solution-like-in-school-by-ol-oj4e | \nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n int plus = 0;\n LinkedList<Integer>res = new LinkedList<>();\n | olsh | NORMAL | 2023-02-15T15:10:13.073589+00:00 | 2023-02-15T15:10:13.073616+00:00 | 42 | false | ```\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n int plus = 0;\n LinkedList<Integer>res = new LinkedList<>();\n for (int i=0;i<num.length || k>0;){\n int currentDigitK = k%10;\n int currenntDigitRes = ((i<num.length)?num[num.length-1-i]:0) +... | 5 | 0 | [] | 0 |
add-to-array-form-of-integer | JAVA SOLUTION || Easy peasy lemon squeezy😊 || SIMPLE | java-solution-easy-peasy-lemon-squeezy-s-tsg4 | \n\n# Code\n\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n List<Integer> list = new ArrayList<>();\n int i = nu | Sauravmehta | NORMAL | 2023-02-15T11:16:18.424142+00:00 | 2023-02-15T11:16:18.424170+00:00 | 525 | false | \n\n# Code\n```\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n List<Integer> list = new ArrayList<>();\n int i = num.length-1;\n int carry = 0;\n while(i >= 0){\n int val = num[i] + (k % 10) + carry;\n if(val > 9){\n list... | 5 | 0 | ['Java'] | 0 |
add-to-array-form-of-integer | Java Solution || The Hard way | java-solution-the-hard-way-by-gau5tam-2741 | Please UPVOTE if you like my solution!\n\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n List<Integer> list = new ArrayL | gau5tam | NORMAL | 2023-02-15T09:48:20.781383+00:00 | 2023-02-15T09:48:20.781418+00:00 | 211 | false | Please **UPVOTE** if you like my solution!\n```\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n List<Integer> list = new ArrayList<>();\n String n = "";\n for(int i = num.length-1;i>=0;i--){\n n += String.valueOf(num[i]); \n }\n StringBuilde... | 5 | 0 | ['Java'] | 0 |
add-to-array-form-of-integer | C++ ||Begineer Friendly|| Easy-Understanding|| Video solution | c-begineer-friendly-easy-understanding-v-uoya | Intuition\n Describe your first thoughts on how to solve this problem. \nC++ Clear Explaination ,Please support if you find it usefull. Can give me feedback in | with_Sky_04 | NORMAL | 2023-02-15T05:46:18.333761+00:00 | 2023-02-15T05:46:18.333791+00:00 | 1,508 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n**C++ Clear Explaination ,Please support if you find it usefull. Can give me feedback in comment for improvement.,will be very thankfull.**\nhttps://www.youtube.com/watch?v=qWmANiGB00I/\n# Approach\n<!-- Describe your approach to solving ... | 5 | 0 | ['Array', 'Math', 'C', 'C++', 'Java'] | 0 |
add-to-array-form-of-integer | 🗓️ Daily LeetCoding Challenge February, Day 15 | daily-leetcoding-challenge-february-day-90c46 | This problem is the Daily LeetCoding Challenge for February, Day 15. Feel free to share anything related to this problem here! You can ask questions, discuss wh | leetcode | OFFICIAL | 2023-02-15T00:00:16.794556+00:00 | 2023-02-15T00:00:16.794623+00:00 | 4,257 | false | This problem is the Daily LeetCoding Challenge for February, Day 15.
Feel free to share anything related to this problem here!
You can ask questions, discuss what you've learned from this problem, or show off how many days of streak you've made!
---
If you'd like to share a detailed solution to the problem, please ... | 5 | 0 | [] | 26 |
add-to-array-form-of-integer | ✅ EASY & BETTER C++ Solution | EXPLAINED | IN-PLACE | O(n) | easy-better-c-solution-explained-in-plac-m26h | Algorithm:\n1. Traversing the vector array from last and continuously adding the last element of integer \'K\'\n\ta. Adding k to num[i]\n\tb. Updating k by num[ | ke4e | NORMAL | 2022-07-12T08:53:59.170867+00:00 | 2022-07-12T08:53:59.170913+00:00 | 508 | false | Algorithm:\n1. Traversing the vector array from last and continuously adding the last element of integer \'K\'\n\ta. Adding k to num[i]\n\tb. Updating k by num[i]/10\n\tb. Updating num[i] by num[i]%10 \n2. If any carry left, it will be inserted at start of the vector array num\n3. Return the array.\n\nTime Complexity:... | 5 | 0 | ['C'] | 0 |
add-to-array-form-of-integer | Java Solution | java-solution-by-ishikaroy0100-95nb | ```\nclass Solution {\n public List addToArrayForm(int[] num, int k) {\n List list=new ArrayList<>();\n int i=num.length-1;\n while(i>=0 | ishikaroy0100 | NORMAL | 2022-01-25T07:00:16.940666+00:00 | 2022-01-25T07:00:16.940704+00:00 | 620 | false | ```\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n List<Integer> list=new ArrayList<>();\n int i=num.length-1;\n while(i>=0 || k>0){\n if(i>=0)\n k=k+num[i];\n list.add(k%10);\n k/=10;\n i--;\n }\n ... | 5 | 0 | ['Java'] | 2 |
add-to-array-form-of-integer | Easiest solution | O(n) | Amazon |Facebook asked | 10 Lines of code | easiest-solution-on-amazon-facebook-aske-ca3w | If you like my approach please do upvote!\n\nIn this we have converted a number to string so that we can add it\'s corresponding values easily!\n\nclass Solutio | astha77 | NORMAL | 2021-01-12T12:21:00.881480+00:00 | 2021-01-12T12:31:16.002531+00:00 | 487 | false | If you like my approach please do upvote!\n\nIn this we have converted a number to string so that we can add it\'s corresponding values easily!\n```\nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& A, int K) {\n vector<int>v;\n string p=to_string(K);\n int l1=A.size()-1;\n ... | 5 | 1 | ['String', 'C'] | 0 |
add-to-array-form-of-integer | JavaScript Solution | javascript-solution-by-deadication-vxqi | \nvar addToArrayForm = function(A, K) {\n // i = current index of array A\n // c = carry\n // k = current least significant digit of K\n // a = curr | Deadication | NORMAL | 2020-04-10T17:10:12.850571+00:00 | 2020-04-10T17:12:56.111679+00:00 | 1,088 | false | ```\nvar addToArrayForm = function(A, K) {\n // i = current index of array A\n // c = carry\n // k = current least significant digit of K\n // a = current least significant digit of A\n // d = current digit to push\n \n const n = A.length\n const temp = []\n let i = n - 1\n let c = 0\n ... | 5 | 1 | ['JavaScript'] | 1 |
add-to-array-form-of-integer | 1 line lazy javascript solution | 1-line-lazy-javascript-solution-by-daima-v32t | \n156 / 156 test cases passed.\nStatus: Accepted\nRuntime: 176 ms\nMemory Usage: 42.1 MB\n\n/**\n * @param {number[]} A\n * @param {number} K\n * @return {numbe | daimant | NORMAL | 2020-04-03T09:09:24.546774+00:00 | 2020-04-03T09:09:24.546809+00:00 | 650 | false | ```\n156 / 156 test cases passed.\nStatus: Accepted\nRuntime: 176 ms\nMemory Usage: 42.1 MB\n\n/**\n * @param {number[]} A\n * @param {number} K\n * @return {number[]}\n */\nvar addToArrayForm = function(A, K) {\n return [...(BigInt(A.join(\'\')) + BigInt(K) + \'\')];\n};\n``` | 5 | 0 | ['JavaScript'] | 0 |
add-to-array-form-of-integer | Accepted Python3: One Liner using map() | accepted-python3-one-liner-using-map-by-j4yk1 | \nclass Solution:\n def addToArrayForm(self, A: List[int], K: int) -> List[int]:\n return list(map(int, list(str(int(\'\'.join(map(str, A))) + K))))\n | i-i | NORMAL | 2019-12-08T18:58:41.898029+00:00 | 2019-12-08T18:58:41.898085+00:00 | 684 | false | ```\nclass Solution:\n def addToArrayForm(self, A: List[int], K: int) -> List[int]:\n return list(map(int, list(str(int(\'\'.join(map(str, A))) + K))))\n``` | 5 | 0 | ['Python', 'Python3'] | 1 |
add-to-array-form-of-integer | ✔️C++ SOLUTION✔️ | c-solution-by-2005115-c9z1 | PLEASE UPVOTE MY SOLUTION IF YOU LIKE IT\n# CONNECT WITH ME\n### https://www.linkedin.com/in/pratay-nandy-9ba57b229/\n#### https://www.instagram.com/pratay_nand | 2005115 | NORMAL | 2023-11-07T17:43:12.135997+00:00 | 2023-11-07T17:43:12.136023+00:00 | 273 | false | # **PLEASE UPVOTE MY SOLUTION IF YOU LIKE IT**\n# **CONNECT WITH ME**\n### **[https://www.linkedin.com/in/pratay-nandy-9ba57b229/]()**\n#### **[https://www.instagram.com/pratay_nandy/]()**\n# Approach\nThe provided C++ code is an updated version of the previous code and defines a class "Solution" with a public member f... | 4 | 0 | ['Array', 'Math', 'C++'] | 0 |
add-to-array-form-of-integer | Easy Java Solution || Using stack | easy-java-solution-using-stack-by-apoora-foa0 | Intuition\n Describe your first thoughts on how to solve this problem. \nTo solve the problem, you can start by converting the array num into an integer, then a | apooravsingh38 | NORMAL | 2023-02-15T08:41:31.847130+00:00 | 2023-02-15T08:41:31.847163+00:00 | 1,048 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo solve the problem, you can start by converting the array num into an integer, then add k to it, and finally convert the result back into an array. However, since the constraints are quite large, you need to be careful about the impleme... | 4 | 0 | ['Java'] | 1 |
add-to-array-form-of-integer | ✅ [Java/C++] 100% Solution using Math (Add to Array-Form of Integer) | javac-100-solution-using-math-add-to-arr-obyn | Complexity\n- Time complexity: O(max(n,m)) \n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(max(n,m))\n Add your space complexity here, e.g | arnavsharma2711 | NORMAL | 2023-02-15T05:27:27.885959+00:00 | 2023-02-15T05:27:27.886011+00:00 | 173 | false | # Complexity\n- Time complexity: $$O(max(n,m))$$ \n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(max(n,m))$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n*where n is size of num vector and m is number of digits in k.*\n\n# Code\n```C++ []\nclass Solution {\npublic:\n ve... | 4 | 0 | ['Math', 'C++', 'Java'] | 0 |
add-to-array-form-of-integer | Golang short and simple solution | golang-short-and-simple-solution-by-traf-r0l0 | Complexity\n- Time complexity: O(n)\n- Space complexity: O(1) - if we don\'t count additional elements produced by k. But it\'s limited to 4 as k <= 10^4\n\n\n# | traffiknewmail | NORMAL | 2023-02-15T03:16:24.879787+00:00 | 2023-02-15T03:20:34.134599+00:00 | 365 | false | # Complexity\n- Time complexity: O(n)\n- Space complexity: O(1) - if we don\'t count additional elements produced by k. But it\'s limited to 4 as k <= 10^4\n\n\n# Code\n```\nfunc addToArrayForm(num []int, k int) []int {\n i := 1\n for k > 0 {\n if len(num) >= i {\n k += num[len(num)-i]\n ... | 4 | 0 | ['Go'] | 0 |
add-to-array-form-of-integer | C++✅✅ | 0ms Faster Solution⏳ | O(1) Space Complexity | Clean and Understandable😇 | c-0ms-faster-solution-o1-space-complexit-dkbz | Code\n# PLEASE DO UPVOTE !\nCONNECT WITH ME ON LINKEDIN : https://www.linkedin.com/in/kunal-shaw-/\n\nclass Solution {\npublic:\n vector<int> addToArrayForm( | kunal0612 | NORMAL | 2023-02-15T02:49:20.873963+00:00 | 2023-02-15T02:49:20.874008+00:00 | 2,347 | false | # Code\n# **PLEASE DO UPVOTE !**\n**CONNECT WITH ME ON LINKEDIN : https://www.linkedin.com/in/kunal-shaw-/**\n```\nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& num, int k) {\n int n=num.size();\n int c=0;\n int i;\n for(i=n-1;i>=0 or k>0;i--){\n int r=k%1... | 4 | 0 | ['Math', 'C++'] | 2 |
add-to-array-form-of-integer | One Liner | parseInt Substitute | one-liner-parseint-substitute-by-aniketc-eyg5 | 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 | aniketcodes | NORMAL | 2023-02-15T02:42:40.313909+00:00 | 2023-02-15T02:42:40.313945+00:00 | 1,151 | 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)$$ --... | 4 | 0 | ['JavaScript'] | 0 |
add-to-array-form-of-integer | Java || BigInteger || Easy to UnderStand | java-biginteger-easy-to-understand-by-ma-ew1o | \nimport java.math.BigInteger;\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n String s="";\n for(int i:num){\n | Manoj_07 | NORMAL | 2023-01-30T17:47:25.066249+00:00 | 2023-01-30T17:47:25.066292+00:00 | 745 | false | ```\nimport java.math.BigInteger;\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n String s="";\n for(int i:num){\n s+=i;\n }\n String kk=k+"";\n List<Integer> al=new ArrayList<>();\n BigInteger a=new BigInteger(s);\n BigInteger... | 4 | 0 | [] | 3 |
add-to-array-form-of-integer | Java simple solution |faster than 97%| | java-simple-solution-faster-than-97-by-u-0v8r | class Solution {\n public List addToArrayForm(int[] num, int k) {\n\t\n int n = num.length;\n int i = n-1;\n List sol = new ArrayList<>( | Ujjwall19 | NORMAL | 2022-09-05T19:31:56.421697+00:00 | 2022-09-05T19:31:56.421741+00:00 | 1,266 | false | class Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n\t\n int n = num.length;\n int i = n-1;\n List<Integer> sol = new ArrayList<>();\n while(i >= 0 || k > 0) { \n if(i >= 0) {\n sol.add((num[i] + k) % 10);\n k = (num[i] + k) / 10;\n... | 4 | 0 | ['Java'] | 0 |
add-to-array-form-of-integer | ✔️Python, C++,Java|| Beginner level ||As Simple As U Think||Simple-Short-Solution✔️ | python-cjava-beginner-level-as-simple-as-4ddm | Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome.\n___\n__\nQ | Anos | NORMAL | 2022-08-26T11:24:47.123749+00:00 | 2022-08-26T11:24:47.123795+00:00 | 779 | false | ***Please upvote to motivate me in my quest of documenting all leetcode solutions. HAPPY CODING:)\nAny suggestions and improvements are always welcome*.**\n___________________\n_________________\n***Q989. Add to Array-Form of Integer***\nThe **array-form** of an integer num is an array representing its digits in left t... | 4 | 0 | ['C', 'Python', 'Java'] | 0 |
add-to-array-form-of-integer | C solution, 98 ms, 15.9 MB | c-solution-98-ms-159-mb-by-uneducatedper-jeyy | \n\n\nint* addToArrayForm(int* num, int numSize, int k, int* returnSize){\n int car = 0; int* returnNum;\n *returnSize = numSize;\n \n for (int i = | uneducatedPerson | NORMAL | 2022-08-06T01:00:12.087454+00:00 | 2022-08-06T01:11:03.418221+00:00 | 393 | false | \n\n```\nint* addToArrayForm(int* num, int numSize, int k, int* returnSize){\n int car = 0; int* returnNum;\n *returnSize = numSize;\n \n for (int i = numSize - 1; i > -1; i--)\n {\n num[i... | 4 | 0 | ['Array', 'C'] | 0 |
add-to-array-form-of-integer | simple C++ code with explanation || comments added | simple-c-code-with-explanation-comments-gr43m | \nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& num, int k) {\n vector<int>ans;\n int carry=0;\n \n int i=num.size()-1 | _RaviPratap_ | NORMAL | 2022-07-17T07:25:39.338352+00:00 | 2022-07-17T07:25:39.338402+00:00 | 600 | false | ```\nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& num, int k) {\n vector<int>ans;\n int carry=0;\n \n int i=num.size()-1;\n while(i>=0 || carry>0 || k!=0 )\n {\n if(k!=0) // here we are adding last digit of k in a[i] from last, and if after adding value is grea... | 4 | 0 | ['C', 'C++'] | 0 |
add-to-array-form-of-integer | JAVA very easy Solution less than 90.59% memory O(n) time | java-very-easy-solution-less-than-9059-m-se50 | Please Upvote if you find this helpful\n\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n List<Integer> list = new ArrayL | nesarptr | NORMAL | 2022-04-03T07:28:45.056183+00:00 | 2022-04-03T07:28:45.056221+00:00 | 255 | false | ***Please Upvote if you find this helpful***\n```\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n List<Integer> list = new ArrayList<>();\n int sum = 0;\n for (int i = num.length; i > 0; i--) {\n if (k > 0) {\n sum = sum + (k % 10) + num[i-... | 4 | 0 | [] | 2 |
add-to-array-form-of-integer | Java | O(n) Time | O(n) Space | java-on-time-on-space-by-hawtsauce-iwnl-b1bu | \nclass Solution {\n // O(n) Time | O(n) Space\n public List<Integer> addToArrayForm(int[] num, int k) {\n int n = num.length;\n ArrayList<I | hawtsauce-iwnl | NORMAL | 2021-08-26T06:42:51.421099+00:00 | 2021-08-26T06:51:23.251461+00:00 | 421 | false | ```\nclass Solution {\n // O(n) Time | O(n) Space\n public List<Integer> addToArrayForm(int[] num, int k) {\n int n = num.length;\n ArrayList<Integer> list = new ArrayList<>();\n for(int i = n - 1; i >= 0; i--) { \n int sum = num[i] + k;\n list.add(sum % 10); // Insertin... | 4 | 0 | ['Java'] | 1 |
add-to-array-form-of-integer | Simple Java Solution | Faster than 99.61% | 2ms | simple-java-solution-faster-than-9961-2m-gmsi | \nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n \n LinkedList<Integer> result = new LinkedList();\n \n | vibhuteevala | NORMAL | 2021-05-27T20:52:15.778102+00:00 | 2021-05-27T20:52:58.422145+00:00 | 475 | false | ```\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n \n LinkedList<Integer> result = new LinkedList();\n \n int sum = 0;\n int carry = 0;\n int i = num.length - 1;\n int data = 0;\n \n while(i >= 0 && k > 0){\n sum... | 4 | 1 | ['Java'] | 0 |
add-to-array-form-of-integer | Python easy solution | python-easy-solution-by-oleksam-r3bc | \nclass Solution:\n def addToArrayForm(self, A: List[int], K: int) -> List[int]:\n # prepare original number\n str_numbers_list = [str(number) | oleksam | NORMAL | 2020-04-01T18:39:39.205759+00:00 | 2020-04-01T18:40:09.094133+00:00 | 311 | false | ```\nclass Solution:\n def addToArrayForm(self, A: List[int], K: int) -> List[int]:\n # prepare original number\n str_numbers_list = [str(number) for number in A]\n number = int("".join(str_numbers_list))\n\n # prepare and return the answer\n number += K\n res = [int(x) for ... | 4 | 0 | [] | 1 |
add-to-array-form-of-integer | Simple and Intutive Solution | simple-and-intutive-solution-by-chauhans-gvv1 | Intuition \n\nThe problem involves adding a large integer represented as an array (num) to another integer (k). The idea is to simulate the addition process as | chauhansujal | NORMAL | 2024-08-09T11:13:22.030799+00:00 | 2024-08-10T19:10:52.119253+00:00 | 306 | false | # Intuition \n\nThe problem involves adding a large integer represented as an array (`num`) to another integer (`k`). The idea is to simulate the addition process as we do manually, digit by digit from right to left.\n\nConsider this example:\n- `num = [1, 2, 3]` (which represents 123)\n- `k = 789`\n\n### The approach:... | 3 | 0 | ['Java'] | 1 |
add-to-array-form-of-integer | Easy & Simple Solution In Java || Sum and Carry Technique 💥👍 | easy-simple-solution-in-java-sum-and-car-styu | Intuition\nsum of last numbers and carry and add to the ans and reverse it.\n\n# Approach\n1. make a list name as a ans.\n2. loop will start begin grom num.leng | Rutvik_Jasani | NORMAL | 2024-02-25T06:42:22.759548+00:00 | 2024-02-25T06:42:22.759581+00:00 | 86 | false | # Intuition\nsum of last numbers and carry and add to the ans and reverse it.\n\n# Approach\n1. make a list name as a ans.\n2. loop will start begin grom num.length-1 to end i>=0 or k!=0.\n3. make sum and carry the value.\n4. reverse the ans liast and returrn it.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space com... | 3 | 0 | ['Array', 'Math', 'Java'] | 0 |
add-to-array-form-of-integer | JavaScript | Beats 100% | Simple Solution | Explained | javascript-beats-100-simple-solution-exp-94qv | \n# Approach\n Describe your approach to solving the problem. \nThe problem appears to be about adding a number represented by an array (num) to another number | eduardko2001 | NORMAL | 2023-12-24T21:04:05.115006+00:00 | 2023-12-24T21:04:05.115025+00:00 | 275 | false | \n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe problem appears to be about adding a number represented by an array (num) to another number k. The array represents a non-negative i... | 3 | 0 | ['JavaScript'] | 0 |
add-to-array-form-of-integer | Java straight froward easy solution ||easy Approach | java-straight-froward-easy-solution-easy-qeia | Intuition\nEasy Java Solution \n\n# Approach\njust like orthodox addition method ie..\n 1 2 \n+ 5\n____\n 1 7\n\nhere we are adding numbers from end of array a | harshverma2702 | NORMAL | 2023-02-16T16:52:34.939082+00:00 | 2023-02-16T16:52:34.939126+00:00 | 131 | false | # Intuition\nEasy Java Solution \n\n# Approach\njust like orthodox addition method ie..\n 1 2 \n+ 5\n____\n 1 7\n\nhere we are adding numbers from end of array a keeping an carry for further addition purpose \n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n) , for answer set List for solution we do ... | 3 | 0 | ['Java'] | 0 |
add-to-array-form-of-integer | 1 line Python Solution || Beats 98.4% in memory | 1-line-python-solution-beats-984-in-memo-8mzb | \n\n# Approach\n Describe your approach to solving the problem. \n1. turn each element on nums into a string \n\nmap(str,num)\n\n2. concate the elements of the | MohMantawy | NORMAL | 2023-02-15T16:29:33.376285+00:00 | 2023-02-15T16:29:33.376316+00:00 | 432 | false | \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. turn each element on nums into a string \n```\nmap(str,num)\n```\n2. concate the elements of the array together\n```\n\'\'.join(map(str,num))\n```\n3. type cast into int and add k\n```\nint(\'\'.join(map(str,num))) + k\n```\n4. type cast into s... | 3 | 0 | ['Python3'] | 1 |
add-to-array-form-of-integer | || 🐍 Python3 || One-Line || Easiest ✔ Solution 🔥 || Beats 66% (Runtime) & 65% (Memory) || | python3-one-line-easiest-solution-beats-n2v0x | Intuition\nEasy problem with one line solution where num list is joined to form an int and then added to k and again converted to list.\n\n# Approach\nAlthough | Samurai_Omu | NORMAL | 2023-02-15T16:27:23.157897+00:00 | 2023-02-15T16:27:23.157942+00:00 | 608 | false | # Intuition\nEasy problem with one line solution where `num` list is joined to form an int and then added to `k` and again converted to list.\n\n# Approach\nAlthough its a one-line solution, there are multiple steps involved.\n1. Iterating through the `nums` list while converting each element to `str` and then joining ... | 3 | 0 | ['Array', 'Math', 'Python3'] | 0 |
add-to-array-form-of-integer | Easy 1 liner in C# with LINQ | easy-1-liner-in-c-with-linq-by-davidlind-hbwc | Here is an easy to understand 1 liner\n\n# Approach\n1. Convert the num array to a string\n2. Parse as a number\n3. Add k\n4. Convert value to string\n5. Conver | davidlindon | NORMAL | 2023-02-15T15:40:47.790674+00:00 | 2023-02-15T15:40:47.790717+00:00 | 474 | false | Here is an easy to understand 1 liner\n\n# Approach\n1. Convert the num array to a string\n2. Parse as a number\n3. Add k\n4. Convert value to string\n5. Convert each element to an int\n6. Build list to return\n\n# Code\n```\nusing System.Numerics;\npublic class Solution {\n public IList<int> AddToArrayForm(int[] nu... | 3 | 0 | ['C#'] | 1 |
add-to-array-form-of-integer | easy solution in c++ | easy-solution-in-c-by-shubhi_115-ihji | Intuition\n Describe your first thoughts on how to solve this problem. \nMove from write to left, k is the carry, add num[i]+k, num[i]=lastdigit\nand k = alldig | shubhi_115 | NORMAL | 2023-02-15T14:38:31.395674+00:00 | 2023-02-15T14:38:31.395723+00:00 | 436 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMove from write to left, k is the carry, add num[i]+k, num[i]=lastdigit\nand k = alldigits except last digit .... do so on.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\... | 3 | 0 | ['C++'] | 1 |
add-to-array-form-of-integer | 0ms/simple java solution/easy to understand/beginner friendly | 0mssimple-java-solutioneasy-to-understan-bdi0 | 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 | antovincent | NORMAL | 2023-02-15T14:22:35.224052+00:00 | 2023-02-15T14:22:35.224096+00:00 | 38 | 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 | ['Java'] | 0 |
add-to-array-form-of-integer | ✅C++ | ✅Easy to Understand | c-easy-to-understand-by-yash2arma-998l | Code\n\nclass Solution \n{\npublic:\n vector<int> addToArrayForm(vector<int>& num, int k) \n {\n int carry=0, sum, i=num.size()-1;\n while(k | Yash2arma | NORMAL | 2023-02-15T08:28:18.499678+00:00 | 2023-02-15T08:28:18.499806+00:00 | 707 | false | # Code\n```\nclass Solution \n{\npublic:\n vector<int> addToArrayForm(vector<int>& num, int k) \n {\n int carry=0, sum, i=num.size()-1;\n while(k || carry)\n {\n sum = carry + k%10;\n k /= 10;\n\n if(i>=0)\n {\n sum += num[i];\n ... | 3 | 0 | ['Array', 'Math', 'C++'] | 0 |
add-to-array-form-of-integer | Super Easy JAVA Sol. | super-easy-java-sol-by-harsh_tiwari-qrwu | 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 | harsh_tiwari_ | NORMAL | 2023-02-15T08:14:26.160706+00:00 | 2023-02-15T08:14:26.160752+00:00 | 345 | 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 | ['Java'] | 0 |
add-to-array-form-of-integer | [Python]Simple solution for noobs (for people new to coding) | pythonsimple-solution-for-noobs-for-peop-thfk | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. Using brute force to look | bot16111011 | NORMAL | 2023-02-15T07:34:55.681656+00:00 | 2023-02-15T07:34:55.681704+00:00 | 194 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->Using brute force to look.\nfirst for loop is used to convert the list to number.\nthen we store the acquired number in **s**\nAdd the k in s then loop the s and enter t... | 3 | 0 | ['Python'] | 0 |
add-to-array-form-of-integer | JAVA EASY to UNDERSTAND Solution | java-easy-to-understand-solution-by-hars-f3oy | \n# Approach\nJUST SIMPLE ADDITION.\n\nTIP : use LinkedList instead of ArrayList.\n\n# Complexity\n- Time complexity : O(n)\n\n- Space complexity: O(1)\n\n# Cod | harshgupta4949 | NORMAL | 2023-02-15T06:37:29.740927+00:00 | 2023-02-15T06:37:29.740970+00:00 | 460 | false | \n# Approach\nJUST SIMPLE ADDITION.\n\nTIP : use LinkedList instead of ArrayList.\n\n# Complexity\n- Time complexity : O(n)\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n int n=num.length;\n List<Integer> l=new LinkedList<>();\n ... | 3 | 0 | ['Linked List', 'Math', 'Java'] | 2 |
add-to-array-form-of-integer | Optimized Solution in C++ | optimized-solution-in-c-by-devanshu_ragh-90ga | Intuition\nWe can optimize the solution to avoid the integer conversion and make it more efficient. Instead of computing the sum of the input integer and k digi | Devanshu_Raghav | NORMAL | 2023-02-15T06:24:08.828180+00:00 | 2023-02-15T06:24:08.828218+00:00 | 406 | false | # Intuition\nWe can optimize the solution to avoid the integer conversion and make it more efficient. Instead of computing the sum of the input integer and k digit by digit, we can directly add k to the least significant digit of the input integer and carry over the result to the higher digits. This way, we can build t... | 3 | 0 | ['Array', 'C++'] | 1 |
add-to-array-form-of-integer | One Line, JS | one-line-js-by-mrsalvation-sbz2 | \n\nconst addToArrayForm = (nums, k) => (BigInt(nums.join(\'\')) + BigInt(k)).toString().split(\'\')\n\n | mrsalvation | NORMAL | 2023-02-15T06:11:38.664890+00:00 | 2023-02-15T06:11:38.664935+00:00 | 859 | false | ```\n\nconst addToArrayForm = (nums, k) => (BigInt(nums.join(\'\')) + BigInt(k)).toString().split(\'\')\n\n``` | 3 | 0 | ['JavaScript'] | 1 |
add-to-array-form-of-integer | Easy approach used in multiple problems | easy-approach-used-in-multiple-problems-htikn | Intuition\nSimilar problems are:\n-> Add Two Numbers\n-> Plus One\n-> Add Binary\n-> Add Strings\n\n# Approach\nfirst convert given k into vector.\nNow place tw | harsh_patell21 | NORMAL | 2023-02-15T05:26:30.811856+00:00 | 2023-02-15T05:26:30.811897+00:00 | 33 | false | # Intuition\nSimilar problems are:\n-> Add Two Numbers\n-> Plus One\n-> Add Binary\n-> Add Strings\n\n# Approach\nfirst convert given k into vector.\nNow place two pointer.\nOne at the last of first vector.\nSecond pointer at the last of second vector.\nThere is also a variable carry which is used for carry as well as ... | 3 | 1 | ['C++'] | 0 |
add-to-array-form-of-integer | || Understandable C++ Solution || | understandable-c-solution-by-shantanubho-6si1 | 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 | shantanubhojak | NORMAL | 2023-02-15T04:58:03.836512+00:00 | 2023-02-15T04:58:03.836559+00:00 | 597 | 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 | ['C++'] | 0 |
add-to-array-form-of-integer | Simple beginner solution || Addition-carry concept ||✔ | simple-beginner-solution-addition-carry-xfrls | \n\nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& num, int k) {\n int n=num.size();\n vector<int> ans;\n int carry | Ayuk_05 | NORMAL | 2023-02-15T04:55:22.621196+00:00 | 2023-02-15T04:55:22.621236+00:00 | 192 | false | \n```\nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& num, int k) {\n int n=num.size();\n vector<int> ans;\n int carry=0;\n for(int i=n-1;i>=0;--i){\n int res=num[i]+k%10+ carry;\n ans.push_back(res%10);\n carry=res/10;\n ... | 3 | 0 | ['Array', 'Math', 'C++'] | 0 |
add-to-array-form-of-integer | Rust easy solution | rust-easy-solution-by-williamcs-3ww6 | \n\nimpl Solution {\n pub fn add_to_array_form(num: Vec<i32>, k: i32) -> Vec<i32> {\n let mut k = k;\n let mut res = vec![];\n let mut j | williamcs | NORMAL | 2023-02-15T03:25:34.864156+00:00 | 2023-02-15T03:25:34.864201+00:00 | 1,444 | false | \n```\nimpl Solution {\n pub fn add_to_array_form(num: Vec<i32>, k: i32) -> Vec<i32> {\n let mut k = k;\n let mut res = vec![];\n let mut j = num.len();\n let mut carry = 0;\n\n while j > 0 || k > 0 || carry > 0 {\n if j > 0 {\n carry += num[j - 1];\n ... | 3 | 0 | ['Rust'] | 0 |
add-to-array-form-of-integer | Java | LinkedList | 10 lines | Beats > 97% | java-linkedlist-10-lines-beats-97-by-jud-nyv4 | 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 | judgementdey | NORMAL | 2023-02-15T00:59:22.310976+00:00 | 2023-02-15T01:01:59.217576+00:00 | 26 | 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: $$O(max(N,logK))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(max(N,logK))$$\n<!-- Add your s... | 3 | 0 | ['Doubly-Linked List', 'Java'] | 0 |
add-to-array-form-of-integer | Python3 🚀🚀|| Simple solution and explained || O(n)👀. | python3-simple-solution-and-explained-on-eqtz | Approach\n Describe your approach to solving the problem. \n- First I converted list into string format in order to make it as number.\n- Then I added the num a | Kalyan_2003 | NORMAL | 2023-02-04T13:22:03.072437+00:00 | 2023-02-04T13:22:03.072479+00:00 | 693 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n- First I converted list into string format in order to make it as number.\n- Then I added the num and K and then converted the result into string again to convert from string format to list and assigned to str_list.\n- Later converted the str_list in... | 3 | 0 | ['Array', 'Math', 'Python3'] | 1 |
add-to-array-form-of-integer | Python3 | One line solution | python3-one-line-solution-by-manfrommoon-kze8 | \nclass Solution:\n def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n return list(str(int("".join([str(x) for x in num])) + k))\n | manfrommoon | NORMAL | 2022-05-14T11:52:34.613474+00:00 | 2022-05-14T12:02:39.029403+00:00 | 519 | false | ```\nclass Solution:\n def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n return list(str(int("".join([str(x) for x in num])) + k))\n``` | 3 | 0 | ['Python', 'Python3'] | 0 |
add-to-array-form-of-integer | Python3 | hold my beer | python3-hold-my-beer-by-anilchouhan181-j9hd | One line solution\n\nclass Solution:\n def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n return [int(i) for i in str(int(\'\'.join([str | Anilchouhan181 | NORMAL | 2022-02-23T19:40:48.118670+00:00 | 2022-02-23T19:40:48.118718+00:00 | 378 | false | **One line solution**\n```\nclass Solution:\n def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n return [int(i) for i in str(int(\'\'.join([str(i) for i in num]))+k)]\n``` | 3 | 1 | ['Python', 'Python3'] | 0 |
add-to-array-form-of-integer | java easy code | java-easy-code-by-rakesh_sharma_4-ybsk | \nclass Solution {\n public List<Integer> addToArrayForm(int[] nums, int k) {\n List<Integer> list=new ArrayList<>();\n int i=nums.length-1;\n | Rakesh_Sharma_4 | NORMAL | 2022-01-21T01:08:15.532339+00:00 | 2022-01-21T01:08:15.532367+00:00 | 327 | false | ```\nclass Solution {\n public List<Integer> addToArrayForm(int[] nums, int k) {\n List<Integer> list=new ArrayList<>();\n int i=nums.length-1;\n while(i>=0 || k>0)\n {\n if(i>=0)\n k=k+nums[i];\n list.add(k%10);\n k/=10;\n i--;\n... | 3 | 0 | ['Java'] | 0 |
add-to-array-form-of-integer | java solution with complete explanation | java-solution-with-complete-explanation-mf09b | \n//refer screenshot for explanation\n\n\nclass Sol | chetandaulani1998 | NORMAL | 2021-12-05T02:06:42.302480+00:00 | 2021-12-05T02:12:26.844340+00:00 | 407 | false | ```\n//refer screenshot for explanation\n\n\nclass Solution {\n public List<Integer> addToArrayForm(int[] num, int k) {\n ArrayList<Integer> list = new ArrayList<>();\n \n for(int i=num.l... | 3 | 0 | ['Java'] | 0 |
add-to-array-form-of-integer | Python 3 | very easy to understand | one-liner | python-3-very-easy-to-understand-one-lin-4f84 | \nreturn list(str(K + int("".join(map(str, A)))))\n | saishivau726 | NORMAL | 2021-01-15T06:58:50.437269+00:00 | 2021-01-15T06:58:50.437311+00:00 | 126 | false | ```\nreturn list(str(K + int("".join(map(str, A)))))\n``` | 3 | 1 | [] | 1 |
add-to-array-form-of-integer | C# O(n) solution | c-on-solution-by-newbiecoder1-c8v4 | Implementation\n Time complexity: O(N) where N is the length of A.\n Traversing the input array takes O(N). List.Add() is a O(1) operation. List.Reverse() is a | newbiecoder1 | NORMAL | 2020-11-11T08:15:59.954016+00:00 | 2020-11-11T08:15:59.954052+00:00 | 172 | false | # Implementation\n* Time complexity: O(N) where N is the length of A.\n Traversing the input array takes O(N). List.Add() is a O(1) operation. List.Reverse() is a O(N) operation. \n \n* Space complexity: O(N)\n```\npublic class Solution {\n public IList<int> AddToArrayForm(int[] A, int K) {\n \n int... | 3 | 0 | [] | 1 |
add-to-array-form-of-integer | Python two solutions: type conversion and normal mod | python-two-solutions-type-conversion-and-sl9t | \nclass Solution:\n def addToArrayForm(self, A: \'List[int]\', K: \'int\') -> \'List[int]\':\n """\n Method 1, convert A to an integer first, d | bigtony | NORMAL | 2019-02-12T18:18:46.169452+00:00 | 2019-02-12T18:18:46.169526+00:00 | 609 | false | ```\nclass Solution:\n def addToArrayForm(self, A: \'List[int]\', K: \'int\') -> \'List[int]\':\n """\n Method 1, convert A to an integer first, do the addition, finally convert to list\n """\n def list2int(l):\n s = list(map(str, l))\n s = \'\'.join(s)\n... | 3 | 1 | [] | 1 |
add-to-array-form-of-integer | C | c-by-pavithrav25-nw27 | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | pavithrav25 | NORMAL | 2024-12-28T04:21:57.781296+00:00 | 2024-12-28T04:21:57.781296+00:00 | 97 | 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 | ['C'] | 0 |
add-to-array-form-of-integer | easy solution | easy-solution-by-leet1101-8hcb | Intuition\nThe problem can be reduced to a simple addition of two numbers: one represented as an array (num) and the other as an integer (k). We need to simulat | leet1101 | NORMAL | 2024-10-01T11:43:34.692642+00:00 | 2024-10-01T11:43:34.692669+00:00 | 196 | false | # Intuition\nThe problem can be reduced to a simple addition of two numbers: one represented as an array (`num`) and the other as an integer (`k`). We need to simulate this addition starting from the least significant digits (rightmost elements) and handling carry over.\n\n# Approach\n1. Start from the rightmost digit ... | 2 | 0 | ['Array', 'Math', 'C++'] | 1 |
add-to-array-form-of-integer | 2 approaches - Using Python Built-In Functions & Maths - Explained with comments | 2-approaches-using-python-built-in-funct-iaaj | Using Built-in functions\n\nimport sys\nclass Solution:\n def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n # Set the maximum number of | TrGanesh | NORMAL | 2024-08-17T17:56:01.608444+00:00 | 2024-08-17T17:56:01.608471+00:00 | 152 | false | #### Using Built-in functions\n```\nimport sys\nclass Solution:\n def addToArrayForm(self, num: List[int], k: int) -> List[int]:\n # Set the maximum number of digits allowed in an integer to handle large numbers\n # sys.set_int_max_str_digits(100000) is used to prevent overflow errors in large integer ... | 2 | 0 | ['Python3'] | 0 |
add-to-array-form-of-integer | Easy Java Solution || Math | easy-java-solution-math-by-ravikumar50-wum5 | 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 | ravikumar50 | NORMAL | 2024-03-20T14:22:33.516895+00:00 | 2024-03-20T14:22:33.516924+00:00 | 227 | 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)$$ --... | 2 | 0 | ['Java'] | 0 |
add-to-array-form-of-integer | Perfectly Solved.. check once.. | perfectly-solved-check-once-by-anshdhard-torw | \n\n# Code\n```\nclass Solution {\npublic:\n vector addToArrayForm(vector& num, int k) {\n vectorans;\n vectorresult;\n reverse(num.begi | anshdhardwivedi23 | NORMAL | 2023-12-10T10:58:48.503594+00:00 | 2023-12-10T10:58:48.503624+00:00 | 349 | false | \n\n# Code\n```\nclass Solution {\npublic:\n vector<int> addToArrayForm(vector<int>& num, int k) {\n vector<int>ans;\n vector<int>result;\n reverse(num.begin(),num.end());\n int i=0;\n int carry=0;\n while(i<num.size() || k || carry){\n // checking the condition i... | 2 | 0 | ['C++'] | 1 |
add-to-array-form-of-integer | Python 95% beats || 2 Approach || Simple Code | python-95-beats-2-approach-simple-code-b-kr75 | If you got help from this,... Plz Upvote .. it encourage me\n# Code\n# Approach 1 Array\n\nclass Solution(object):\n def addToArrayForm(self, A, K):\n | vvivekyadav | NORMAL | 2023-09-25T08:31:43.560812+00:00 | 2023-09-25T08:31:43.560836+00:00 | 342 | false | **If you got help from this,... Plz Upvote .. it encourage me**\n# Code\n# Approach 1 Array\n```\nclass Solution(object):\n def addToArrayForm(self, A, K):\n A[-1] += K\n for i in range(len(A) - 1, -1, -1):\n carry, A[i] = divmod(A[i], 10)\n if i: A[i-1] += carry\n if carry... | 2 | 0 | ['Array', 'Math', 'Python', 'Python3'] | 0 |
add-to-array-form-of-integer | Easy Approach ( C++ ) | easy-approach-c-by-yashikagupta14-8dn5 | 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 | YashikaGupta14 | NORMAL | 2023-08-26T03:53:17.065419+00:00 | 2023-08-26T03:53:17.065440+00:00 | 854 | 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)$$ --... | 2 | 0 | ['C++'] | 1 |
add-to-array-form-of-integer | C++|| 98.6% | c-986-by-shradhaydham24-hb45 | 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 | shradhaydham24 | NORMAL | 2023-08-02T13:02:23.822353+00:00 | 2023-08-02T13:02:23.822375+00:00 | 642 | 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)$$ --... | 2 | 0 | ['C++'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.