- 115
- 9 644
The CodeBreakz Show
India
Приєднався 30 тра 2023
Follow the CodeWithEase channel on WhatsApp:
whatsapp.com/channel/0029VaUDt2Q23n3kqYyoP43U
whatsapp.com/channel/0029VaUDt2Q23n3kqYyoP43U
Suite Solutions Voyagehack 2.O TBO hackathon
Welcome to The CodeBreakz Show,
your ultimate destination for all things coding!
Whether you're a beginner just starting your programming journey or an experienced developer looking to expand your skills, we have something for everyone. Our channel features a wide variety of content, including:
Tutorials: Step-by-step guides to help you master different programming languages and technologies.
Live Coding Sessions: Watch and learn as we tackle real-world projects and solve coding challenges in real-time.
Project Builds: Follow along with detailed walkthroughs of exciting projects to enhance your portfolio.
Tips & Tricks: Quick tips and best practices to improve your coding efficiency and productivity.
We cover an extensive range of programming languages and frameworks, from Python and JavaScript to more specialized tools like TensorFlow and React.
Our mission is to make coding accessible and enjoyable for everyone. Join our community of learners and developers, and start building your coding skills today!Don’t forget to like, subscribe, and hit the bell icon to stay updated with our latest videos.
Happy coding!
your ultimate destination for all things coding!
Whether you're a beginner just starting your programming journey or an experienced developer looking to expand your skills, we have something for everyone. Our channel features a wide variety of content, including:
Tutorials: Step-by-step guides to help you master different programming languages and technologies.
Live Coding Sessions: Watch and learn as we tackle real-world projects and solve coding challenges in real-time.
Project Builds: Follow along with detailed walkthroughs of exciting projects to enhance your portfolio.
Tips & Tricks: Quick tips and best practices to improve your coding efficiency and productivity.
We cover an extensive range of programming languages and frameworks, from Python and JavaScript to more specialized tools like TensorFlow and React.
Our mission is to make coding accessible and enjoyable for everyone. Join our community of learners and developers, and start building your coding skills today!Don’t forget to like, subscribe, and hit the bell icon to stay updated with our latest videos.
Happy coding!
Переглядів: 27
Відео
2558. Take Gifts From the Richest Pile |Leetcode problem of the day | Python
Переглядів 21Місяць тому
2558. Take Gifts From the Richest Pile |Leetcode problem of the day | Python Github Code Link : Python : github.com/Prathameshghod/2558.-Take-Gifts-From-the-Richest-Pile/blob/main/2558. Take Gifts From the Richest PileLeetcode Problem of the day Donation Form Link: docs.google.com/forms/d/e/1FAIpQLScyIg4N2ytKxKuqmU96636GZpdQy7PxvP35LghFcrehukueUQ/viewform Let's Connect Instagram 📷: instagram.co...
2779. Maximum Beauty of an Array After Applying Operation |Leetcode problem of the day | Python
Переглядів 20Місяць тому
2779. Maximum Beauty of an Array After Applying Operation |Leetcode problem of the day | Python Github Code Link : Python : github.com/Prathameshghod/2779.-Maximum-Beauty-of-an-Array-After-Applying-Operation/blob/main/2779. Maximum Beauty of an Array After Applying Operation Leetcode Problem of the day Donation Form Link: docs.google.com/forms/d/e/1FAIpQLScyIg4N2ytKxKuqmU96636GZpdQy7PxvP35LghFc...
🎯🔥1760. Minimum Limit of Balls in a Bag |Leetcode problem of the day | Python🔥🎯
Переглядів 26Місяць тому
🎯🔥1760. Minimum Limit of Balls in a Bag |Leetcode problem of the day | Python🔥🎯l Github Code Link : Python : github.com/Prathameshghod/2554.-Maximum-Number-of-Integers-to-Choose-From-a-Range-I-/blob/main/2554. Maximum Number of Integers to Choose From a Range I Leetcode Problem of the day Donation Form Link: docs.google.com/forms/d/e/1FAIpQLScyIg4N2ytKxKuqmU96636GZpdQy7PxvP35LghFcrehukueUQ/view...
🎯🔥2554. Maximum Number of Integers to Choose From a Range I |Leetcode problem of the day | Python🔥🎯
Переглядів 16Місяць тому
2554. Maximum Number of Integers to Choose From a Range I |Leetcode problem of the day | Python Github Code Link : Python : github.com/Prathameshghod/2554.-Maximum-Number-of-Integers-to-Choose-From-a-Range-I-/blob/main/2554. Maximum Number of Integers to Choose From a Range I Leetcode Problem of the day Donation Form Link: docs.google.com/forms/d/e/1FAIpQLScyIg4N2ytKxKuqmU96636GZpdQy7PxvP35LghF...
2109. Adding Spaces to a String | Leetcode problem of the day | Python
Переглядів 82Місяць тому
2109. Adding Spaces to a String | Leetcode problem of the day | Python Github Code Link : Python : github.com/Prathameshghod/2109.-Adding-Spaces-to-a-String/blob/main/2109. Adding Spaces to a String Leetcode Problem of the day Donation Form Link: docs.google.com/forms/d/e/1FAIpQLScyIg4N2ytKxKuqmU96636GZpdQy7PxvP35LghFcrehukueUQ/viewform Let's Connect Instagram 📷: the_codebreakz_sh...
1455. Check If a Word Occurs As Prefix of Any Word in Sentence |Leetcode problem of the day | Python
Переглядів 31Місяць тому
1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence |Leetcode problem of the day | Python Github Code Link : Python : github.com/Prathameshghod/1455.-Check-If-a-Word-Occurs-As-a-Prefix-of-Any-Word-in-a-Sentence/blob/main/1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Problem of the day Donation Form Link: docs.google.com/forms/d/e/1FAIpQLScyIg4N2ytKxK...
🎯🔥1346. Check If N and Its Double Exist | Python | Beats 100%🎯🔥
Переглядів 14Місяць тому
🎯🔥1346. Check If N and Its Double Exist | Python | Beats 100%🎯🔥 Github Code Link : Python : github.com/Prathameshghod/1346.-Check-If-N-and-Its-Double-Exist/blob/main/1346. Check If N and Its Double Exist Leetcode Problem of the day Donation Form Link: docs.google.com/forms/d/e/1FAIpQLScyIg4N2ytKxKuqmU96636GZpdQy7PxvP35LghFcrehukueUQ/viewform Let's Connect Instagram 📷: the_codebrea...
3370. Smallest Number With All Set Bits | Leetcode Weekly Contest 426 | Python
Переглядів 36Місяць тому
3370. Smallest Number With All Set Bits | Leetcode Weekly Contest 426 Github Code Link : Python : github.com/Prathameshghod/3370.-Smallest-Number-With-All-Set-Bits/blob/main/3370. Smallest Number With All Set Bits Leetcode Problem of the day Donation Form Link: docs.google.com/forms/d/e/1FAIpQLScyIg4N2ytKxKuqmU96636GZpdQy7PxvP35LghFcrehukueUQ/viewform Let's Connect Instagram 📷: th...
Codechef starters 154 | Calorie Limit | Add 1 or 2 Game | GCD and XOR | Python Solution
Переглядів 1013 місяці тому
Codechef starters 154 | Add 1 or 2 Game | GCD and XOR | Python Solution Github Link of code ( All in One ) : github.com/Prathameshghod/Codechef-Starters-154/blob/main/Starters 154 Calorie Limit Add 1 or 2 Game GCD and XOR docs.google.com/forms/d/e/1FAIpQLScyIg4N2ytKxKuqmU96636GZpdQy7PxvP35LghFcrehukueUQ/viewform Let's Connect Instagram 📷: the_codebreakz_show?igsh=MTAzMWk0NHhoYzZnM...
1497. Check If Array Pairs Are Divisible by k |Leetcode problem of the day | Python
Переглядів 593 місяці тому
1497. Check If Array Pairs Are Divisible by k |Leetcode problem of the day | Python Github Code Link : Python : github.com/Prathameshghod/1497.-Check-If-Array-Pairs-Are-Divisible-by-k/blob/main/1497. Check If Array Pairs Are Divisible by k Leetcode Problem of the day Donation Form Link: docs.google.com/forms/d/e/1FAIpQLScyIg4N2ytKxKuqmU96636GZpdQy7PxvP35LghFcrehukueUQ/viewform Let's Connect Ins...
1381. Design a Stack With Increment Operation | Implementing Stack in Python | Leetcode POTD| Python
Переглядів 323 місяці тому
1381. Design a Stack With Increment Operation | Implementing Stack in Python | Leetcode POTD| Python
641. Design Circular Deque | Implementing Circular Deque in Python | Leetcode | Python
Переглядів 283 місяці тому
641. Design Circular Deque | Implementing Circular Deque in Python | Leetcode | Python
729. My Calendar I | 2 Approach | 🔥🎯PYTHON 🔥🎯 |Leetcode POTD
Переглядів 224 місяці тому
729. My Calendar I | 2 Approach | 🔥🎯PYTHON 🔥🎯 |Leetcode POTD
Codechef starters 153 | Butterfly | Make Arithmetic Progression | Another Game | Colorful Tree(Easy)
Переглядів 594 місяці тому
Codechef starters 153 | Butterfly | Make Arithmetic Progression | Another Game | Colorful Tree(Easy)
539. Minimum Time Difference | 2 Approach | 🔥🎯PYTHON 🔥🎯 |Leetcode POTD
Переглядів 504 місяці тому
539. Minimum Time Difference | 2 Approach | 🔥🎯PYTHON 🔥🎯 |Leetcode POTD
Leetcode Weekly Contest 415 Solution |Two Sneaky Numbers of Digitville | Maximum Multiplication Scor
Переглядів 754 місяці тому
Leetcode Weekly Contest 415 Solution |Two Sneaky Numbers of Digitville | Maximum Multiplication Scor
947. Most Stones Removed with Same Row or Column | Simple DFS | 🔥🎯PYTHON 🔥🎯 |Leetcode POTD
Переглядів 334 місяці тому
947. Most Stones Removed with Same Row or Column | Simple DFS | 🔥🎯PYTHON 🔥🎯 |Leetcode POTD
476. Number Complement | Two Approaches | Simulation | Bit Masking 🔥🎯PYTHON 🔥🎯 |Leetcode POTD
Переглядів 405 місяців тому
476. Number Complement | Two Approaches | Simulation | Bit Masking 🔥🎯PYTHON 🔥🎯 |Leetcode POTD
264. Ugly Number II Python and C++| 🔥🎯PYTHON VS C++ 🔥🎯 |Leetcode POTD
Переглядів 445 місяців тому
264. Ugly Number II Python and C | 🔥🎯PYTHON VS C 🔥🎯 |Leetcode POTD
Leetcode Weekly Contest 411 Solution | Count Substring That Satisfy K-Constraints I | Maximum Energy
Переглядів 995 місяців тому
Leetcode Weekly Contest 411 Solution | Count Substring That Satisfy K-Constraints I | Maximum Energy
Leetcode Biweekly Contest 137 Contest Solution | Find the Power of K-Size Subarrays I and II
Переглядів 665 місяців тому
Leetcode Biweekly Contest 137 Contest Solution | Find the Power of K-Size Subarrays I and II
860. Lemonade Change Python and C++| 🔥🎯PYTHON VS C++ 🔥🎯 |Leetcode POTD
Переглядів 305 місяців тому
860. Lemonade Change Python and C | 🔥🎯PYTHON VS C 🔥🎯 |Leetcode POTD
Codechef Starters 147 Explanat | Independence Day 101 | Truth Tellers and Liars 101 | Non-Primes 101
Переглядів 645 місяців тому
Codechef Starters 147 Explanat | Independence Day 101 | Truth Tellers and Liars 101 | Non-Primes 101
719. Find K-th Smallest Pair Distance Python and C++| 🔥🎯PYTHON VS C++ 🔥🎯 |Leetcode POTD
Переглядів 375 місяців тому
719. Find K-th Smallest Pair Distance Python and C | 🔥🎯PYTHON VS C 🔥🎯 |Leetcode POTD
703. Kth Largest Element in a Stream Python and C++| 🔥🎯PYTHON VS C++ 🔥🎯 |Leetcode POTD
Переглядів 265 місяців тому
703. Kth Largest Element in a Stream Python and C | 🔥🎯PYTHON VS C 🔥🎯 |Leetcode POTD
1568. Minimum Number of Days to Disconnect Island Python and C++| 🔥🎯PYTHON VS C++ 🔥🎯 |Leetcode POTD
Переглядів 515 місяців тому
1568. Minimum Number of Days to Disconnect Island Python and C | 🔥🎯PYTHON VS C 🔥🎯 |Leetcode POTD
885. Spiral Matrix III Python and C++| 🔥🎯PYTHON VS C++ 🔥🎯 |Leetcode POTD
Переглядів 1035 місяців тому
885. Spiral Matrix III Python and C | 🔥🎯PYTHON VS C 🔥🎯 |Leetcode POTD
Codechef Starters 146,Contest Explanation | No Winner | Knockout Tournament | Permutation Constructi
Переглядів 1355 місяців тому
Codechef Starters 146,Contest Explanation | No Winner | Knockout Tournament | Permutation Constructi
3016. Minimum Number of Pushes to Type Word II Python and C++| 🔥🎯PYTHON VS C++ 🔥🎯 |Leetcode POTD
Переглядів 765 місяців тому
3016. Minimum Number of Pushes to Type Word II Python and C | 🔥🎯PYTHON VS C 🔥🎯 |Leetcode POTD
Keep it up
@@HarryWillson-u2b Yes I will 😊
❤️🎉🙌🏻✨
This can also be fixed by setting the material to double sided but it comes with an additional computational Cost
Very informative and nice explanation .. found this explanation very helpful ❤️🙌🏻✨
Chal bata kya padhaya maine 😂😂
search drawtocode
Thanks for telling i will surely make use of it
@@CodeBreakz Thanks for your interest! 😊 Use DrawToCode at 75% zoom for the best experience, and don't forget to refresh the page after adjusting. Happy coding!
@@CodeBreakz Thanks for your interest! 😊 Use DrawToCode at 75% zoom for the best experience, and don't forget to refresh the page after adjusting. Happy coding!
@@CodeBreakz Thanks for your interest! 😊 Use DrawToCode at 75% zoom for the best experience, and don't forget to refresh the page after adjusting. Happy coding!
@@CodeBreakz Thanks for your interest! 😊 Use DrawToCode at 75% zoom for the best experience, and don't forget to refresh the page after adjusting. Happy coding!
Aap konse college mai hai
Sorry bro but i cant share it you can contact me on insta link is in description
Nice ! Keep it up 👍🏻✨👏🏻👏🏻
Thank you! 😃
Amazing explanation ! ❤️👍🏻✨
Glad you liked it
Bro if array is 0 , 6 , 7 for 2nd question what should be the output? YES or NO
It would be No Just a simple logic first number is 0 so we cant iterate through it 2nd number is 6 so set b= { 6 : 1 } And count += 1 --> 1 3rd number is 7 so set b = { 6:1 , 7:1 } And count +=1 --> 2 Now finally our count total is 2 which is greater than 1 Count > 1 so answer is No
bro in last question u didn't explain that how u generated that formula
@@StrawDev basically it calculates the ascii value of 1st and last charecter of string we put base value as 2 and sum of 2 zero charecters and then subtracted the 0th char and the last char basically The formula is designed to calculate a result based on the ASCII values of the characters at the ends of the binary string, with adjustments and normalization factors. The min(..., n) ensures the result is within the length of the string, handling specific constraints or requirements of the problem.
Nice
Thanks
Kya aap contest ke que bhi karayege
Yes for sure
Bhaiyaa aap ki rating kya hai codechef mai
3*
Bhaiya kuch tips do na 😋
You can contact me on my instagram handle instagram.com/urs_p_ubuntu?igsh=MTAzMWk0NHhoYzZnMg==
Bhaiya aap toh itne hushaar ho , aap toh Google mai honge na 🤔🤗
No actually I am a student
Very nice !! Explanation keep it up ❤️👏🏻👏🏻👍🏻
Thank you! 😃
Nice explanation
Nice explanation
Nice explanation
dark mode
Bhai, contest ko mazaak kyun banake rakha hai, ye rating talented logo ko apna capabilities dikhane ka ek jariya hai, please chhod de
Bro, I know you are very honest, but why are you coming and looking at contest solutions? These are meant to help beginners, not for people preparing for Google interviews like you.
@@CodeBreakz I too came but not to look at your solutions but to report the channel xD
bro how to visualize python code?
You have to just read the code line by line for each iteration . I have uploaded more precise Explanation in drive: drive.google.com/file/d/1MzNDI2hLlTuPHSJmyFVnIXeo8EPpTne8/view?usp=drivesdk then also if you have any doubt you can comment me
@@CodeBreakz thank you🙏
@@CodeBreakz thank you for sharing drive... I'm freshie learning dsa, already I studied ml... after watching tutorial in dsa I'm unable to solve any problem should I just read others code n dry code it or something else should I do??
Listen try to solve easy level problems in leetcode or any other platforms practice it and then move on the medium level problems which are of the same type For example : 1. Minimum Number of K Consecutive Bit Flips 2. Minimum Operations to Make Binary Array Elements Equal to One I Both are of same type just way to solve and approach varies so try to solve easy level problems then go on same type problem but with more difficulty and try solving problem by yourself first then if you feel you can see other code but try to understand how the loops try to find the answer
@@CodeBreakz I'll surely follow this technique thank you🙏
Hlo bro
Hello !!
bahut kharab explanation
I will try to improve thank you for your response
Bhai tujhse nahi hoga rehne de 😂
Thanks for your feedback! I'll keep working on improving my content.
Amazing explanation!... Thank you:)
Glad you liked it
Java code Scanner scanner = new Scanner(System.in); int T = scanner.nextInt(); scanner.nextLine(); // consume the newline after T int[] results = new int[T]; for (int i = 0; i < T; i++) { String S = scanner.nextLine(); int min_horizontal = 0, max_horizontal = 0, min_vertical = 0, max_vertical = 0; if (S.charAt(0) == '1') { min_horizontal = -10; } if (S.charAt(1) == '1') { max_horizontal = 10; } if (S.charAt(2) == '1') { max_vertical = 10; } if (S.charAt(3) == '1') { min_vertical = -10; } int number_of_cells = (max_horizontal - min_horizontal + 1) * (max_vertical - min_vertical + 1); results[i] = number_of_cells; } for (int result : results) { System.out.println(result); }
Python code import sys input_func = sys.stdin.read data = input_func().split() T = int(data[0]) results = [] for i in range(1, T + 1): S = data[i] min_horizontal, max_horizontal = 0, 0 min_vertical, max_vertical = 0, 0 if S[0] == '1': min_horizontal = -10 if S[1] == '1': max_horizontal = 10 if S[2] == '1': max_vertical = 10 if S[3] == '1': min_vertical = -10 number_of_cells = (max_horizontal - min_horizontal + 1) * (max_vertical - min_vertical + 1) results.append(number_of_cells) for result in results: print(result)
Java code Scanner scanner = new Scanner(System.in); // Number of test cases int numTestCases = scanner.nextInt(); // To store the results for each test case int[] results = new int[numTestCases]; for (int testCase = 0; testCase < numTestCases; testCase++) { // Size of the array int arraySize = scanner.nextInt(); int[] array = new int[arraySize]; // Input array elements for (int i = 0; i < arraySize; i++) { array[i] = scanner.nextInt(); } // Calculate the total sum of the array int totalSum = 0; for (int num : array) { totalSum += num; } if (totalSum % 2 == 0) { // If total sum is even, the largest subarray is the entire array results[testCase] = arraySize; } else { // If total sum is odd, find the first and last odd element indices int leftOddIndex = -1; int rightOddIndex = -1; for (int i = 0; i < arraySize; i++) { if (array[i] % 2 != 0) { leftOddIndex = i; break; } } for (int i = arraySize - 1; i >= 0; i--) { if (array[i] % 2 != 0) { rightOddIndex = i; break; } } // Determine the largest subarray length with even sum by removing one odd element if (leftOddIndex == 0 || rightOddIndex == arraySize - 1) { results[testCase] = arraySize - 1; } else { results[testCase] = Math.max(arraySize - 1 - leftOddIndex, rightOddIndex); } } } // Print all results for (int result : results) { System.out.println(result); } scanner.close();
Python code # Number of test cases num_test_cases = int(input()) # To store the results for each test case results = [] for test_case in range(num_test_cases): array_size = int(input()) array = list(map(int, input().split())) total_sum = sum(array) if total_sum % 2 == 0: # If total sum is even, the largest subarray is the entire array results.append(array_size) else: # If total sum is odd, find the first and last odd element indices left_odd_index = -1 right_odd_index = -1 for i in range(array_size): if array[i] % 2 != 0: left_odd_index = i break for i in range(array_size - 1, -1, -1): if array[i] % 2 != 0: right_odd_index = i break # Determine the largest subarray length with even sum by removing one odd element if left_odd_index == 0 or right_odd_index == array_size - 1: results.append(array_size - 1) else: results.append(max(array_size - 1 - left_odd_index, right_odd_index)) # Print all results for result in results: print(result)
i dont get this logic....please explain bro
I have uploaded a video explanation of this question you can see that by the way sorry bro for late reply
i understood the logic it was difficult to understand in first try😅@@CodeBreakz
import sys input = sys.stdin.read # Read the input data = input().split() T = int(data[0]) results = [0] * T sum_of_first_nine = 45 # 1 + 2 + ... + 9 index = 1 for i in range(T): N = int(data[index]) index += 1 full_cycles = N // 9 remainder = N % 9 # Sum from complete cycles and the remaining part result = full_cycles * sum_of_first_nine + (remainder * (remainder + 1)) // 2 results[i] = result # Output the sum of original values for res in results: print(res)
def count_non_consecutive_pairs(s, n): count_pairs = 0 i = 1 while i < n: if s[i] == s[i - 1]: count_pairs += 1 i += 1 i += 1 return count_pairs def main(): num_test_cases = int(input()) for _ in range(num_test_cases): length = int(input()) moves = input() result = count_non_consecutive_pairs(moves , length) print(length- result) if __name__ == "__main__": main()
import java.util.*; import java.lang.*; import java.io.*; class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner scanner = new Scanner(System.in); int cases = scanner.nextInt(); for (int k = 0; k < cases; k++) { int amount = scanner.nextInt(); int year = scanner.nextInt(); int result = 0; for (int i = 0; i < year; i++) { if (amount * 2 > amount + 1000) { amount *= 2; result = amount; } else { amount += 1000; result = amount; } } System.out.println(result); } scanner.close(); } }
# cook your dish here for k in range(int(input())): amount,year=map(int,input().split()) result=0 for i in range(year): if(amount*2>amount+1000): amount*=2 result=amount else: amount+=1000 result=amount print(result)
t=int(input()) for i in range(t): n=int(input()) # n is number of integers in n array a=list(map(int,input().split())) subarray = [1]*n # initialises a list subarray of length n with all elements set to 1 # last element always though it may be positive or negative for i in range(n-2,-1,-1): if (a[i]*a[i+1]<0): # 2 -2 -3 # -3*-2==6>0 #last second element is 1 # -2*2=-4<0 # last third element is 1+1=2 # subarray= 2 1 1 subarray[i]=subarray[i+1]+1 else: subarray[i]=1 print(*subarray) # subarray 2 1 1 without* it will print 211 which will give error
whatsapp.com/channel/0029VaUDt2Q23n3kqYyoP43U
class Solution: def isPalindrome(self, x: int) -> bool: if x < 0: return False reversed_num = 0 temp = x while temp != 0: digit = temp % 10 reversed_num = reversed_num * 10 + digit temp //= 10 return reversed_num == x
whatsapp.com/channel/0029VaUDt2Q23n3kqYyoP43U
class Solution { public int[] twoSum(int[] nums, int target) { Map<Integer,Integer> map= new HashMap<>(); // Map and HashMap these are in built codes for writing HashMap for(int i=0;i<nums.length;i++){ // nums={2,7,11,15} and our target element is target=9 // nums.length=4 int substract= target-nums[i]; // substract=9-nums[0 // substract =9-2=7 if(map.containsKey(substract)){ return new int[]{ map.get(substract),i}; } map.put(nums[i],i); } throw new IllegalArgumentException(" No 2 sums have solution"); } }
whatsapp.com/channel/0029VaUDt2Q23n3kqYyoP43U
# Code by Prathamesh Ghodmare class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): # nums=[2,7,11,15] # len(nums)=4 for j in range(i+1,len(nums)): #i+1=0+1=1 #len(nums)=4 #j will start from 1 to 4 if nums[j]==target-nums[i]: #nums[j]=7. and target=9. also nums[i]=2 # 7==9-2 return [i,j]
whatsapp.com/channel/0029VaUDt2Q23n3kqYyoP43U
whatsapp.com/channel/0029VaUDt2Q23n3kqYyoP43U
whatsapp.com/channel/0029VaUDt2Q23n3kqYyoP43U
import java.util.*; import java.lang.*; import java.io.*; class Codechef { public static void main(String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t > 0) { int n = sc.nextInt(); int arr[] = new int[n + 1]; for (int i = 1; i <= n; i++) { arr[i] = sc.nextInt(); } long ans = 0; for (int i = 1; i <= n; i++) { long left = (long) arr[i]; if (left == 1) { ans += (long) n; } else { long power = 1; for (int j = 1; j <= n; j++) { power *= left; if (power > 1000000000L) { break; } else { long right = (long) arr[j]; if (power <= right) { ans++; } } } } } System.out.println(ans); t--; } } }
import java.util.*; class Codechef { public static void main(String[] args) throws java.lang.Exception { Scanner jk = new Scanner(System.in); int t = jk.nextInt(); while (t > 0) { int vk = jk.nextInt(); PriorityQueue<Integer> max = new PriorityQueue<>(Collections.reverseOrder()); PriorityQueue<Integer> min = new PriorityQueue<>(); for (int j = 0; j < vk; j++) { int va = jk.nextInt(); max.add(va); min.add(va); } int ans = 0; int to = vk / 2; while (to > 0) { int ge = max.poll(); int small = min.poll(); int df = ge - small; ans += df; to--; } if (vk % 2 != 0) { ans += min.poll(); } System.out.println(ans); t--; } } }