![]() ![]() Please note that this approach will return all the three indexes as well, if they add up to the target. To review, open the file in an editor that reveals hidden Unicode characters. If not then return None, return the indexes otherwise. facebook.py This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. ![]() Then I used list manipulation to sum all the possible combination of numbers in your input array, then I just check in one shot if the target is inside the sum array or not. I used the itertools to make all the combination of the numbers for me. I was trying your example for my own learning. Matching_combination = subsets #gets the option #Checks sum of all the posible combinations clear Adalah perintah untuk membersihkan layar pada terminal. ![]() chmod Adalah perintah untuk merubah izin akses file atau direktori. cd Adalah perintah untuk mengakses suatu direktori Contoh : cd /sdcard 6. Print(subsets) #returns all the posible combinations as tuples, note not permutations! apt upgrade Adalah perintah meningkatkan versi paket yang ada ke versi yang terbaru. Output returns null on test case with target 6, so indices 1 and 2 aren't even being summarized, could I be assigning y wrong?įor subset in binations(nums, L): I miss on test case with the target number of 6, which should return the indices of, but hit on test case with the target number of 6 (which of course returns indices ), so it appears that something is wrong in my while loop, but I'm not quite sure what. You may assume that each input would have exactly one solution, and you may not use the same element twice. Given an array of integers, return indices of the two numbers such that they add up to a specific target. On this classic question my code misses a test case. I'm new to Python and have just started to try out LeetCode to build my chops. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |