ความคิดเห็น •

  • @codetips-byRochak
    @codetips-byRochak 22 ชั่วโมงที่ผ่านมา

    Let's Connect 🤝 :
    LinkedIn : www.linkedin.com/in/rochak-vyas17/
    Code :-
    class Solution {
    public:
    int pairsum(vector &arr) {
    int n=arr.size();
    int maxi=INT_MIN;
    for(int i=0;imaxi){
    maxi=arr[i];
    }
    }
    int secmaxi=INT_MIN;
    for(int i=0;isecmaxi&&arr[i]

  • @dhairyapandya5550
    @dhairyapandya5550 14 ชั่วโมงที่ผ่านมา

    Instead of using O(2N).
    I have solved it in O(N), here is my approach
    class Solution {
    public:
    int pairsum(vector &arr) {
    // code here
    int greater1=arr[0];
    int greater2=arr[1];
    int n=arr.size();
    for(int i=2;i

    • @codetips-byRochak
      @codetips-byRochak 14 ชั่วโมงที่ผ่านมา +1

      Yes, so instead of using two for loops, you have written multiple if else condition inside one for loop. So yeah that's great, and thanks for your kind words.😀