LeetCode Problem and Answer
- Anand Nerurkar
- Jan 20
- 1 min read
Updated: Jan 24
Climbing Stair




Valid Paranthesis








remove element
==




rotate array
==







Integer to Roman
===


two sum
===

find min no in sorted and rotated array
===

find missing no

==
min no of platform
===

find leader in array
==
How to remove duplicate element from sorted array




How to rotate an array by k times
===


if k=-1, then right rotate and k=k+lengh of array
k= + ve, then left rotate



move zero to end of array
===



how to find a leader in array
===
Leader is a element > all elelemtns to its right side. right most element is always a leader.

freq of element in a sorted array
===


max sum of subarray of size 3
===
sum 42

sum 36

sum 48

sum 24


Find max subaaray sum
===






KEdan Algorithm
==
8 > maxsum , no , no changes to maxsum
if >, maxsum=sum;




this is max subarray sum.

find meadian of 2 sorted array
==


public static float medianof2sortedarrray(int[]a,int[]b){
int i=j=k=0;
int m[]=new int[a.length +b.length]
while(i<a.length && j < b.length){
if(a[i] <b[j]){
m[k]=a[i];
i++;
K++;
}else{
m[k]=b[j];
k++;
j++;
}
}//while end
while(i<a.length){
m[k]=a[i];
i++;k++;
}
while(j<b.length){
m[k]=b[j];
j++;
k++;
}
int mid=0;
if(m.length%2==0){
mid=m.length/2;
return (flaot)(m[mid]+m[mid-1]/2);
}else{
mid=m.length/2;
return m[mid];
}
time com=big o(m+n)
find given array is sorted or not
==

Comments