3 Sum - Target Sum Unique Triplets | Leetcode 15 Solution in Hindi

Поделиться
HTML-код
  • Опубликовано: 21 июн 2021
  • Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
    NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. 1. Given an integer array 'nums', and a 'target', return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k.
    2. Another thing is nums[i] + nums[j] + nums[k] == target.
    3. Notice that the solution set must not contain duplicate triplets.
    Topic: #twoPointerApproach, #twoSum, #Sorting
    Used #DataStructure: #Arrays
    #TimeComplexity: O(n^2)
    #SpaceComplexity: O(1)
    --------------------------------------------------------------
    Linked Questions:
    1. Two Sum - Target Sum Unique Pair: • 2 Sum - Target Sum Uni...
    --------------------------------------------------------------
    For a better experience and more exercises, VISIT: www.pepcoding.com/resources/
    Have a look at our result: www.pepcoding.com/placements
    Follow us on our RUclips page: / pepcoding
    Follow us on our FB page: / pepcoding
    Follow us on Instagram: / pepcoding
    Follow us on LinkedIn: / pepcoding-education
    Follow us on Pinterest: / _created
    Follow us on Twitter: home
    .
    .
    .
    Happy Programming !!! Pep it up 😍🤩
    .
    .
    .
    #pepcoding #code #coder #codinglife #programming #coding #java #freeresources #datastrucutres #pepcode #competitive #competitiveprogramming #softwareengineer #engineering #engineer

Комментарии • 35

  • @RishabhRJ04
    @RishabhRJ04 2 года назад +8

    Bhai bhai bhai bhai
    0:24

    • @Pepcoding
      @Pepcoding  2 года назад

      Hope you like the video.
      For better experience and well organised content sign up on nados.io and don't forget to follow us on Instagram instagram.com/pepcoding/

    • @nishantagarwal5274
      @nishantagarwal5274 2 года назад

      😂😂

    • @ArvindSrawat-fz4qc
      @ArvindSrawat-fz4qc 2 года назад

      threesum

    • @lakshrustagi507
      @lakshrustagi507 2 года назад

      F

  • @anuragdogra9204
    @anuragdogra9204 3 года назад +6

    i think time complexity analysis is also more important while writing the code, so please add tc.

  • @pabitrasarkar203
    @pabitrasarkar203 Год назад +1

    sir in line number 44 why in the for loop you use i

  • @mrprime557
    @mrprime557 2 года назад +1

    Great explanation. Please add time complexity Analysis to videos. Thank you

    • @Pepcoding
      @Pepcoding  2 года назад

      Everything is precisely arranged on nados.pepcoding.com
      Don't forget to follow us on Instagram instagram.com/pepcoding/

  • @raj14318
    @raj14318 2 года назад +1

    great explaination brother🔥🔥🔥

    • @Pepcoding
      @Pepcoding  2 года назад

      Glad you liked it, for better experience and curated content sign up on nados.io, you can also post your queries on community tab of NADOS.

  • @CarelessMni
    @CarelessMni Год назад

    Thanks Sir.

  • @aniketgahiware6592
    @aniketgahiware6592 2 года назад +1

    Amazing.......

    • @Pepcoding
      @Pepcoding  2 года назад

      Thanks for watching. Please refer to nados.pepcoding.com for best experience.
      Also don't forget to follow us on Instagram.

  • @darshankalathiya8667
    @darshankalathiya8667 2 года назад

    for(int i = 0 ; i

  • @LegitGamer2345
    @LegitGamer2345 3 года назад +1

    question not available on portal

  • @SumitSingh-ui4do
    @SumitSingh-ui4do 2 года назад

    Amazing❤️❤️

    • @Pepcoding
      @Pepcoding  2 года назад

      Glad you liked it.
      Keep learning
      And for better experience and well organised content visit nados.pepcoding.com

  • @Saurabh-fe2bg
    @Saurabh-fe2bg Год назад

    what if the target is not given and we are asked to find the triplets in an array

  • @raj14318
    @raj14318 2 года назад

    please one suggetion every program u should explain about TC...

  • @mickyman753
    @mickyman753 2 года назад

    ye ques shayad rajnish sir ne bhi ek baar karay tha

  • @kirtikedia6274
    @kirtikedia6274 2 года назад +2

    Your solution will fail for following testcase - [0,0,0,0,0]
    Your code will return - [[0,0,0],[0,0,0]]
    Where else expected output would be - [[0,0,0]]
    To fix,
    if(sum == find){
    ans.push_back({arr[i],arr[start],arr[end]});
    while(start

  • @kanareikaTv
    @kanareikaTv 2 года назад

    Что ж, матан научил нас китайскому, программирование научило меня хинди

  • @nikhilkumarjamwal5322
    @nikhilkumarjamwal5322 2 года назад

    Code is not showing the desired output.
    class Solution {

    public List twoSum(int[] nums, int s, int e, int t) {
    // 1 1 2 3 4 5 6 7 7
    int start=s, end=e, target=t, sum=0;
    List l = new ArrayList();

    while(start < end){ // log(n)
    if(start != s && nums[start] == nums[start-1]){
    start++;
    continue;
    }
    sum = nums[start] + nums[end];
    if(sum == target){//element found
    List l1 = new ArrayList();
    l1.add(nums[start]);
    l1.add(nums[end]);
    l.add(l1);
    start++;
    end--;
    }
    else if(sum > target){
    end--;
    }
    else if(sum < target){
    start++;
    }
    }
    return l;
    }

    public List threeSum(int[] nums) {
    List l = new ArrayList();
    int target = 0, oldTarget = 0, value = 0;
    if(nums.length < 3){
    return l;
    }

    Arrays.sort(nums);

    for(int i=0; i

  • @aahanaganjewar9951
    @aahanaganjewar9951 2 года назад

    if(l != si && nums[l] == nums[l-1] ){
    l++;
    continue;
    }
    I didn't understand why l != si?

    • @codersaurabh6231
      @codersaurabh6231 2 года назад

      When you will do l-1 which means start-1 since l= start, so to exclude the beginning case try to think taking start as 0 you will get clear idea.

    • @aahanaganjewar9951
      @aahanaganjewar9951 2 года назад

      @@codersaurabh6231 Thank you!

  • @shubhamkhuntia2412
    @shubhamkhuntia2412 2 года назад

    It's showing TLE
    class Solution {
    public List twoSum(int arr[],int si,int ei,int target){
    int left = si;
    int right = ei;
    List ans = new ArrayList();
    while(left target){
    right--;
    } else {
    left++;
    }
    }
    return ans;
    }
    public List threeSum(int[] arr) {
    Arrays.sort(arr);
    int target =0;
    List res = new ArrayList();
    int n=arr.length;
    if(n

    • @Pepcoding
      @Pepcoding  2 года назад

      For better insights, visit nados.pepcoding.com, post your doubts, community will help you out there.

    • @amanbisht4286
      @amanbisht4286 2 года назад +1

      Should have used Arrays.sort(nums) over there

    • @omkarkulkarni3207
      @omkarkulkarni3207 2 года назад +1

      In twoSum() method : if(sum==target) --> You forgot to do left++; right--;

  • @shreyashree6781
    @shreyashree6781 3 года назад

    agar main function me kaise implement kiya h , wo v batate to acha hota...qk video complete explaination wali honi chahye k .

  • @anubhavnegi4230
    @anubhavnegi4230 2 года назад +2

    kind of seems like u have learned the solution not a good way to explain, kindly be intuitive ;)