class Solution { public int maximumCount(int[] nums) { int negcount=0; int poscount=0; int ans=0; for(int i=0;i
@unknownuser-h9r24 күн бұрын
macha we can also consider leftmost of zero and right most of zero. i sovled in this way.
@ajayramavath841324 күн бұрын
Did this in my first try ->Found left most of zero and right most of zero and solved : public static int maximumCount(int[] nums) { int l = left(nums); int r = right(nums); return Math.max(l, nums.length - r - 1); } private static int left(int[] nums) { int start = 0; int end = nums.length - 1; int target = 0; while (start = target) { end = mid - 1; } else { start = mid + 1; } } return start; } private static int right(int[] nums) { int start = 0; int end = nums.length - 1; int target = 0; while (start target) { end = mid - 1; } else { start = mid + 1; } } return end; } Did this after the second hint -> Found left most of Zero and One and solved.: public static int maximumCount2(int[] nums) { int l = left(nums, 0); int r = left(nums, 1); return Math.max(l, nums.length - r); } private static int left(int[] nums, int target) { int start = 0; int end = nums.length - 1; while (start = target) { end = mid - 1; } else { start = mid + 1; } } return start; }
@ivsc24 күн бұрын
tried and colved it macha class Solution { public int maximumCount(int[] nums) { int c1=bsn(nums,0); int c2=bsn(nums,1); System.out.println(c1+" "+c2); return Math.max(c1, nums.length-c2); } public int bsn(int[] nums,int num) { int low=0,high=nums.length-1; while(low=num) { high=mid-1; } else low=mid+1; } return high+1; } }
@Naveen_Reddy1723 күн бұрын
Dont stop till we get enough 😅
@saitejamukkerla21 күн бұрын
2nd attempt left most of 1 and right most of -1 chesa class Solution { public int maximumCount(int[] arr) { int pos=Bsl(arr,1); int neg=Bsr(arr,-1); int positive=arr.length-pos; int negitive=neg+1; return Math.max(positive,negitive); } public static int Bsl(int []arr,int target){ int low=0; int high=arr.length-1; while(low=target){ high=mid-1; } else{ low=mid+1; } } if(low
@rikkiteja431723 күн бұрын
Enti macha channel pettina starting loni break lu vundavu ani cheppav but intha valuable content neripisthu break lu isthunav maa lanti vallani andarni disappoint chesthunnav
@engineeringanimuthyam23 күн бұрын
@@rikkiteja4317 video cmng macha eroju kuda uploading lo undhi 🤧
@edevenkatarajesh26223 күн бұрын
Brute force approach Time complexity is : O(n) Space complexity is : O(1) class Solution { public int maximumCount(int[] nums) { int n = nums.length; int neg = 0; int pos = 0; for (int i = 0; i < n; i++) { if (nums[i] < 0) { neg++; } else if (nums[i] > 0) { pos++; } } return Math.max(neg, pos); } } 💫💫💫💫
@WORK-HARD-jm4cg24 күн бұрын
solution chudakunda class Solution(object): def maximumCount(self, nums): count1=0 count2=0 for i in range(len(nums)): if nums[i] >0: count1=count1+1 elif nums[i]
@Ammuuuammu-jf7hn23 күн бұрын
Hii bro tcs code vita gurchi kodha chepandii bro ela preape avali ani plss ❤
@WORK-HARD-jm4cg24 күн бұрын
class Solution(object): def maximumCount(self, nums): x=self.countpositive(nums) y=self.countnegative(nums) print(y) return max(x,y) def countpositive(self,nums): l=0 r= len(nums)-1 while l0 and(mid==0 or nums[mid-1]
@satyateja-ls7pk23 күн бұрын
solved it in 1st attempt macha❤ class Solution { public int lzero(int[] nums){ int l =0; int ansl=0; int r = nums.length-1; int target=0; while(l=target){ r = mid-1; } else l = mid+1; } return l; } public int rzero(int[] nums){ int l =0; int ansr=0; int r = nums.length-1; int target=0; while(l
@Bhargav32074 күн бұрын
macha without any helps and hints try chesa used left most and right most of 0 to get the answer class Solution { public int left(int[] nums){ int l=0; int r=nums.length-1; while(l
@sathvikchintalapudi49624 күн бұрын
macchhaa andharu edho comments peduthunte lite theeskunna kaani ee video lo nuv just chinna hint ivvagaane bale solution vacchindhi macchaa nijam ga edho teliyani excitement plzz macchaa ee series matram nuv asalu aapaku
@engineeringanimuthyam24 күн бұрын
🎊
@jaswanthandhavarapu432524 күн бұрын
class Solution { public int maximumCount(int[] nums) { int countP = firstAndLastP(nums,false) - firstAndLastP(nums,true); int countN = firstAndLastN(nums,false) - firstAndLastN(nums,true); int max = Math.max(countP,countN); return max; } public int firstAndLastN(int[] nums, boolean findFirst){ int low = 0; int high = nums.length - 1; while(low
@WORK-HARD-jm4cg24 күн бұрын
Sorry to ask you again and again . But thappatle macha . Please em anukoku . Estimated month ? For the completion of entire DSA ? Cheppu macha kastha . Memu oka preparation lo untam
@jaswanthandhavarapu432524 күн бұрын
bro naku telisi oka 4 - 5 months padutundhi because he is explaining all types of problems which we will be asked in online assements and online interviews
@engineeringanimuthyam24 күн бұрын
Inko 2 months lo basics ante under 10 lpa lopu adigevi finish cheyali next 2 months lo motham dsa finish cheyali
@lavan111915 күн бұрын
class Solution { public static int pos(int[] nums) { int l = 0; int r = nums.length - 1; while (l 0) { l = mid; if (mid > 0 && nums[mid - 1] > 0) { l = mid - 1; } else { return r - l + 1; } } else { r = mid - 1; } } return 0; } public int neg(int[] nums) { int l = 0; int r = nums.length - 1; while (l