Binary search is POSSIBLE here. We can determine which element should be present at ith index using simpe A.P formula and if correct element present, move right else move left side. Thanks for this content.
@Its_Abhi_Thakur2 жыл бұрын
let arr = [5, 7, 9, 11, 15, 17]; let missing = 0; for (let i = 0; i < arr.length; i++) { let el = arr[i]; let next_el = arr[i + 1]; if (next_el - el !== 2) { missing = el + 2; break; } } console.log(missing);
@coderdost2 жыл бұрын
good and simple
@Its_Abhi_Thakur2 жыл бұрын
@@coderdost thank you 😇
@ahmadraiyan1654 ай бұрын
let arr=[5,7,9,11,15,17] let arr2=[] for (let i = 0; i < arr.length; i++) { if ((arr[i]-arr[i-1])!==2&&(arr[i]-arr[i-1])==4) { arr2.push(arr[i-1]+2) } } console.log(arr2);
my code works with any case: const input = [1,2,3,4,5,6,7,9]; function checkMate(arr) { let diff = arr[1] - arr[0]; let i = 0; let j = arr.length-1; let ans; while (i < j) { if(arr[i] + diff === arr[i+1]) { i++; } else { ans = arr[i] + diff; console.log(ans); break; } } } checkMate(input);
@YouTubeflixyt2 жыл бұрын
Great quality content keep it up❤️
@ApurvaKashyap-kj6qz Жыл бұрын
Because binary search is applicable where we r given a target number to search in an array .. which is not in this case .
@itechinnovations2200 Жыл бұрын
Map all the values inside array then go for a loop that iterates within the req range then for each odd no check it is present in map or not if not then print and break
@khanapeena21918 ай бұрын
in your code for loop should iterate till array.length-1
@Rubyd777 Жыл бұрын
I guess using some mathematics can be helpful. But i would use it only if array was large and we need to solve it in minimum time complexity else i would use sorting approach 1) Find max and min at once from array 2)find sum of odd numbers from 1 to nth term(let x) 3)find total sum of elemnts given in array (let y) 4)find total sum of odd number from min to max that we found above(let z) 5)lastly: (x-y)-(x-z) This can be simplified but you compolsary need x to find y and z Please correct if i am wrong. I just ried my approach
@PunkSage4 ай бұрын
There is even a much simpler approach. Find my comment above.
@abnow1998 Жыл бұрын
It is in AP(Arithmetic Progression) Just check Common Difference. Formula: a+(n-1)*d a is first number, d is common diff
@shazaibahmad780711 ай бұрын
Bro simple is that one if condition if(arr[I+1]-arr[I]===4) { return are[I+1]+2; } else{ return; }
@Rohit-zs7kn2 жыл бұрын
const arr = [5, 7, 9, 11, 13, 15, 17, 21]; let index = 0; for (let oddNum = arr[0]; oddNum
@yesuraju-tf1yp Жыл бұрын
function missOdd(arr){ let first=0, last=arr.length-1, mid = 0 ,first_element = arr[0]; if(first_element+2*last == arr[last] ) return "no element is missed"; while(first
@PunkSage4 ай бұрын
Shortest I could think of: const i = [5,7,9,11,15,17]; const find = (a)=> { const f = (a[0] + a[a.length-1])/2*(a.length+1); const s = a.reduce((t, c)=> t+c, 0); return f-s; } console.log(find(i));
@werecoders3 ай бұрын
Very simple for (let index = 0; index < num.length; index++) { let current = num[index]; let next = current + 2; if (num.includes(next)) { continue; } else { console.log(next); break; } }
@vin23682 жыл бұрын
const Arr3 = [6,9,12,18,24,30] const n = 3 function getMissingOddNumbers(arr){ let output=[]; for(let i = 0;i
@MehulJadavIndia Жыл бұрын
const input = [5, 7, 9, 11, 13, 15, 17, 21]; for (i = 0; i
@AbdurRahimKhan-gz1jo Жыл бұрын
Hey, @coderdost please do more videos like this...
@AashMusic1 Жыл бұрын
const lst = [5, 7, 9, 11, 15, 17]; let res = [] for (let i =0 ; i < lst.length; i++){ let current = lst[i] let nextOdd = current + 2 if(lst[i+1]===nextOdd){ continue; }else{ res.push(nextOdd); break; } } console.log(res)
@sannisinha58 Жыл бұрын
It's very helpful... please continue😊
@rahulkr73492 жыл бұрын
the question was simple. not that hard but the interview makes your heartbeat sound like a banging drum.
@coderdost2 жыл бұрын
Yeah its the pressure which acts..
@AkashSingh-xf6bd Жыл бұрын
let input =[5,7,11,13,15,17]; let out = 13 function s(input){ for(let i= 0; i
@sanvijha2 жыл бұрын
We can not apply binary search for this problem as we have to evaluate key from the array itself.
@madhursangeet29 Жыл бұрын
const input = [1,5,7,9,11,15,17,21,25]; let inputFirst = input[0]; let inputEnd = input.at(-1); let missDigit = []; for(let i = inputFirst; i
@happylaughy2777 Жыл бұрын
const arr= [3,5,7,9,13] let odd=arr[0]; for(let i=0;i
@syedwaseem37935 ай бұрын
function findMissingOddNumber(numbers) { // Loop through the array of numbers for (let i = 0; i < numbers.length - 1; i++) { // Check if the next number is not exactly 2 more than the current number if (numbers[i + 1] - numbers[i] !== 2) { // If not, the missing number is between these two numbers return numbers[i] + 2; } } // Return null if no number is missing return null; } const input = [5, 7, 9, 11, 15, 17]; const missingNumber = findMissingOddNumber(input); console.log(missingNumber); // Output: 13
@WalkingtotheTruth Жыл бұрын
Binary Search is possible here is the answer: function findMissingOddNumber (arr) { let left = 0 let right = arr.length - 1 let startingNumber = arr[0] let ans = -1 while (left
@GurpreetSingh-gogsy Жыл бұрын
const input = [5,7,9,11,15,19]; for(let i=1;i
@rahil5162 жыл бұрын
First view ; Sir your videos are very helpful appreciated
@40fps143 Жыл бұрын
for last question i thought of this -- console.log(input.map((el) => el *n))
@NavneetTaneja-d1y Жыл бұрын
easy first sort then extract min and max after than loop range from min to max than extrat odd number list that number not in arr that is missing after first missing get break the array
@mohaimin95 Жыл бұрын
function missingOdd(arr) { for(let i = 1; i < arr.length; i++) { const last = arr[i - 1]; const current = arr[i]; if(current - last > 2) { return last + 2; } } }
@mohammedrayyan30298 ай бұрын
const input7 = [5, 7, 9, 11, 15, 17, 21, 25]; const output7 = 13; function missingNumber(input7) { let index; for (index = 0; index < input7.length; index++) { if (input7[index] > output7) { break; } } input7.splice(index, 0, output7); return input7; } console.log(missingNumber(input7), "missing");
@yournanban38128 ай бұрын
const input = [5,7,9,11, 15,17]; let missingNum = ""; for(let i= 0 ; i < input.length; i++){ if (input[i] + 2 != input[i+1]){ missingNum = input[i]+2; break; } } console.log(missingNum) //output missing odd number is 13
Good logic. only thing use forEach in place of map. Map should only be used when array output is expected. Since map builds a new array, calling it without using the returned array is an anti-pattern. Reference : [developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map]
@bathininaveen5198 Жыл бұрын
function findMissingOdd(arr){ for(let i =0;i 2) return arr[i] + 2; } return "No element is Missing!" }
@akash_gupta_2090 Жыл бұрын
Missing odd numbers function missingFirstOddNumbers(arr) { const len = arr.length; let missingNumber = null; for (let i = 0; i < len; i++) { let _curr = arr[i]; let next = arr[i + 1]; if (next - _curr != 2) { missingNumber = _curr + 2; break; } } return missingNumber; }
@abdulbasith650 Жыл бұрын
let arr = [1,3,5,7,9,13] function misodd(arr){ let misnum; for(let i=0;i
@akkburf5450 Жыл бұрын
let arr = [5,7,9,11,15,17] function missNumber(arr){ for(let i =0 ; i < arr.length ; i++ ){ if(!(arr[i] + 2 === arr[i + 1])) return arr[i] + 2 } } console.log(missNumber(arr))
@tonmaysardar3331 Жыл бұрын
const input=[1,3,5,7,11,13,15,17] let b; for (let i=1;i
@namangaur53292 жыл бұрын
Binary search is not helpful in this case bcz in binary search we find a given number within array. But here the number itself not determined. So first we need to find the number and then we can use the bs to find the appropriate position for the number. I'm hoping that the answer is correct..😅 But this type of content is really helpful for us ... Thank u sir for making such type of content❣️
@coderdost2 жыл бұрын
True story
@WalkingtotheTruth Жыл бұрын
Binary Search is possible here is the answer: function findMissingOddNumber (arr) { let left = 0 let right = arr.length - 1 let startingNumber = arr[0] let ans = -1 while (left
@WalkingtotheTruth Жыл бұрын
@@pawansinghrawat7886 const mid = Math.floor((left + right) / 2) this is the mid,we are traversing logn times not whole array,you can run this code and anlysis yourself, thank you.
@notyournormaldev1419 Жыл бұрын
yes it is possible, i am the one in this video@@WalkingtotheTruth
@jsview5315 Жыл бұрын
Hi sir I am fresher Frontend dev i have completed projects and portfolio too and have little bit DSA knowledge but Machine coding and this type question se daar lgta hai so job ki tention aa rahi hai . Please suggest anything
@coderdost Жыл бұрын
Everyone fears such questions as they are matter of practice. So just keep doing such questions more and more. And in real round they will feel simpler. Without practice it will be hard
@jsview5315 Жыл бұрын
@@coderdost Thanks for the reply sir your content is awesome.
@nevilmistry7402 жыл бұрын
const arr = [3,5,7,9,11,13,17,19] //op -> 13 const arrLength = arr.length; let checker = 3 console.log(check(arr,arrLength,checker)) function check(arr,arrLength,checker){ for(i=0;i
@enthusiatic_coder6801 Жыл бұрын
const input = [5, 7, 9, 11, 13, 17, 19, 21]; const compare = (a, b) => { return a - b; }; for (let i = 0; i < input.length; i++) { // console.log(input[i]); if (input[i] - input[i + 1] !== -2) { console.log('The missing number is', input[i] + 2); input.push(input[i] + 2); input.sort(compare); break; } } console.log(input);
@brainnbeyond Жыл бұрын
what I had done for(let i=0; i< input.length; i++){ if(input[i+1] - input [i] > 2){ console.log(input[i] + 2) } } is it right ?
@coderdost Жыл бұрын
yes. replacing 2 by "n" can make it more dynamic to and useful fo any kind Arithmetic progression
@addep-kardy Жыл бұрын
This does work fine! const inp = [5,7,9,11,15,17]; const outp = []; for(let i=0; i < inp.length; i++){ if(inp[i]+2 != inp[i+1]){ outp.push(inp[i]+2); } } console.log(outp);
@prathamlashkari4230 Жыл бұрын
let input = [5, 7, 9, 11,15, 17]; for (let i = 0; i < input.length; i++) { let diff = input[i + 1]-input[i]; if (diff !== 2){ console.log(input[i]+2); break; } }
@arbazhussain67512 жыл бұрын
Sir, I have tried to solve this question. Is it correct? // find the first missing ODD number let input = [5,7,9,11,15,17]; for(let i = input[0]; i < input[input.length-1]; i++){ if(i % 2 !== 0){ if(!input.includes(i)){ console.log(i); break; } } }
@coderdost2 жыл бұрын
Even though it works. But there are some unnecessary iterations like "i" is 5,6,7,8,9 etc.. these values are not all needed like 6, 8 , 10 etc. You can optimize this solution to a more simpler method.
@rajatraj31602 жыл бұрын
sort the array use map and return the element which which has remainder 1. Or u can use sort along with map
@coderdost2 жыл бұрын
@@rajatraj3160 array is already sorted.. so its even simpler now. and we can't evaluate using remainder, as here all numbers are ODD only. problem is to find out 1 missing number from sequence.
@AbhishekKumar-xw1cm2 жыл бұрын
see this let input = [5,7,9,11,15,17] let n = 2 const findMissing = (input,n) => { for(let i =0 ; i < input.length ;i++){ if(input[i]+n !== input[i+1]){ return input[i]+n } } } console.log(findMissing(input,n))
@lalitsinghnegi15622 жыл бұрын
aaj meri joining thi or m MERN stack profile ke liye gya tha or saalo ne python ( flask ) ka project de dia ... pehle se bna hua tha ab usme new functionalities dd krni h or mujhe python aati h nhi .. ab m kya kru
@coderdost2 жыл бұрын
I think learn python because JS and python are almost same. and flask is much easier like express kzbin.info/www/bejne/Z3yWq62lpK98gK8
@lalitsinghnegi15622 жыл бұрын
@coderdost aap shi keh rhe h but agr wo pehle ye baat bta dete ya post m mentioned kr dete to m join hi nhi krta .. but ab bna hua project h to mere kch samjh m aa nhi rha h .. smjh nhi aara kya kru
@coderdost2 жыл бұрын
There are some hard realities of tech sector...they hire for some profile but give work in some other...specially to freshers.. Its hard to judge many companies..
@lalitsinghnegi15622 жыл бұрын
@coderdost yes bro .. i think i should quit ...
@coderdost2 жыл бұрын
In sab facts ko batane k liye ek alag channel banane ka socha h ... soon will plan.. code wale channel pe to mix nhi krenge
@AbhishekSharma-fg1ho Жыл бұрын
its front end dev interview?? and which type of qus asking in front end dev
@coderdost Жыл бұрын
its only coding round for javascript (front-end). which is not compulsory in all companies Some other interview playlists: REACT Interview Shorts : bit.ly/3VfIrMi JAVASCRIPT Interview Shorts: bit.ly/3XhHRQ1 More REACT video Interviews - bit.ly/3QAjAln
@tejasshinde2011 Жыл бұрын
let temp =input[0]; for (let i = 0; i < input.length && input.includes(temp + 2); i++, temp += 2); console.log(temp + 2);
@FarhanKhan-ox4iy Жыл бұрын
I see in the comments no one has used two pointers for this. With that we can achieve linear time complexity. Use start and end. Run while loop until end >= start. start++ and end--
@PunkSage4 ай бұрын
No reason to use it here. All you need to do is to calculate the sum of numbers.
@nevilmistry7402 жыл бұрын
2 nd answer const arr = [5,7,9,11,13,17,19] const arrLength = arr.length; let checker = 3 console.log(check(arr,arrLength,checker)) function check(arr,arrLength,checker){ for(i=1;i
@nevilmistry7402 жыл бұрын
just remove console😅😅😅
@nitishgupta8393 Жыл бұрын
Q1: const missingOdd =(arr)=> { for(let i=0; i
@chiraglegend2670 Жыл бұрын
function nextOdd(input){ for(let i=0 ; i < input.length ; i++){ let val = input[i]+2 if(val != input[i+1]){ return val } } }
@rajatgour9686 Жыл бұрын
ok so let assume given arry is sorted const input = [5,7,9,11,15,17] let output = null for(let start = input[0]+2;start
@Doglapan64 Жыл бұрын
for (let i=0; i
@AvadheshVerma24 Жыл бұрын
for (let i = 0; i < arr.length; i++) { let c = arr[i]; let next = c + 2; if (!arr.includes(next)) { console.log(next); break; } }
@DhirajkaReview26 Жыл бұрын
Sir one question currently i am cdac student they teaches so many concepts rapidly and some topics I don't understand so can u tell me about is that our interview is which base and how should I have to prepare for interview the level Interview they can u tell me about that ??
@coderdost Жыл бұрын
for long term only your knowledge matter, how many projects you have worked on. What you can make. preparing for interview is only a short term things for placements. Interviews are mostly based on popular tricky questions. Just go on internet and check the question related to JS or React. Same 50 questions are asked mostly We made a playlist of popular question in JS and React here : REACT Interview Shorts : bit.ly/3VfIrMi JAVASCRIPT Interview Shorts: bit.ly/3XhHRQ1
@DhirajkaReview26 Жыл бұрын
@@coderdost thanks sir , i saved those playlist and sir one more thing as knowledge perspective my explanation and understanding is good but sometimes I can't write because of syntax is that ok ? As i herad from student interview just how much i understand and even if writte normal code they say is ok for them to hire , like now they start adv java as seen jdbc code to connect i don't they will write that whole code in 1 hour interview can tell me about those things , i have your adv java one video also for reference 🤓 can explain this point how much interview can ask like 5 min code on notepad ?
@coderdost Жыл бұрын
@@DhirajkaReview26 Most of them look for approach rather than exact code. So your code or Pseudocode should explain the steps. They look if you can think of logic, why this logic, what are limitation of that logic, are their any bounds in which that logic will work, are there performance issue with that logic,... They try to change some part of that question also - to check if you can now think of different logic also, to check if you have not mugged up from somewhere. If they have to check syntax and code prefection they will always ask to code on some machine.
@DhirajkaReview26 Жыл бұрын
@@coderdost thank u so much to clear my questions, getting proper suggestions and knowledge From u it's so much for me , thanks lot 🙏
@DeepakGupta-yk2ep Жыл бұрын
Sir please make more Javascript interview videos
@coderdost Жыл бұрын
Yes 👍🏻
@harshjoshi6496 Жыл бұрын
@coderdost Binary search is possible here, Solution: (Explanation at last) const input = [5, 7, 9, 11, 15, 17,19, 21]; first = 0 last = input.length-1 mid = (first+last)/2 while (first
@coderdost Жыл бұрын
nice exaplanation
@ankursharma1822 Жыл бұрын
let arr = [5,7,9,11,15,17]; for(value of arr){ let a = value +2; if(!arr.includes(a)){ console.log(a); break } }
@niju7489 Жыл бұрын
//AP addition formula s= n/2(frst +last) let len = input.length ; return (input[0] +input[len-1])(len+1)/2 - input.reduce((a,c)=>a+c);
To change my algorithm to multiple of three, I have to increase the temp to 3.
@suryateja9881 Жыл бұрын
My solution for Sum 1: let input = [21,23,25,27,31,33,35,37,39,41,45,47,49,53]; for (let i=input[0];i
@AkashSingh-xf6bd Жыл бұрын
Coder Dost, Hi I did not get you "n" concept in last can you explain me
@coderdost Жыл бұрын
like here N was 2. as each next number was +2. So just asked if we can code for any AP series like 3,6,9 - where N=3 and so on.
@AkashSingh-xf6bd Жыл бұрын
@@coderdost okay, now I get this
@nikhilnikki9627 Жыл бұрын
IS THIS CORRECT WAY: const input=[5,7,9,11,15,17] let first =input[0] for (let i of input){ if (i ===first){ let next = first+2 first=next } else{ console.log(first) } }
@coderdost Жыл бұрын
yes, but I think you can remove "first" and use only 1 variable "next" let next =input[0] for (let i of input){ if (i ===next){ let next = next+2 } else{ console.log(next) } }
@maazhasan-mi8le Жыл бұрын
input.forEach((element,index)=>{ if (element + 2 !== input[index + 1] && input.length > index + 1) { console.log('missing number is ', element + 2) } } )
@Doglapan64 Жыл бұрын
@coderDost Please let us know how to break forEach loop ? without using try-catch
@PIYUSH-lz1zq2 жыл бұрын
Bro , coding rounds ks ek alag se playlist bana do !!!
@coderdost2 жыл бұрын
Will do
@PIYUSH-lz1zq2 жыл бұрын
@@coderdost u uploaded only 2 video on js coding round ??
@coderdost2 жыл бұрын
@@PIYUSH-lz1zq 3 videos. all in react interview playlist right now.. will move to separate one
@sumitkumar-in2si2 жыл бұрын
Is this correct? let input=[5,7,9,11,15,17]; for(let i=0;i
@coderdost2 жыл бұрын
Yes
@coffee0919 Жыл бұрын
function findOdd(arr) { for (let i = 0; i < arr.length; i++) { if (arr[i] + 2 !== arr[i + 1]) { return arr[i] + 2; } } return -1; } Is that work?
let arr = [1, 5, 7, 9, 11,13]; let j = arr[0]; for (let i = 0; i < arr.length; i++) { if (arr[i] !== j) { console.log(j) break } j+= 2 } KeepItSimple
@veinzo1jsx Жыл бұрын
Can you please tell me sir how much experience he has.....
@coderdost Жыл бұрын
Fresher
@nazirrizwan2 жыл бұрын
Sir how apply and what procedure to all about this interview
@coderdost2 жыл бұрын
There is a form which was put on community tab. Or directly book slot via emailing us. Email is in about us section. Business email section
@adnaan28 Жыл бұрын
const data = [5, 7, 11, 15, 17] for(let i =data[0]; i
@kiranm5419 Жыл бұрын
const input = [3,5,7,9,11,15,17]; for(let i=0;i
@darklord9500 Жыл бұрын
function findMissingNumber(arr) { let missingNumber = null; for (let i = 0; i < arr.length; i++) { if (arr[i] !== arr[0] + i * 2) { missingNumber = arr[0] + i * 2; break; } } return missingNumber; }
@Snagesh37702 жыл бұрын
const input = [5, 7, 9, 11, 15, 17]; function missingOddNumbers(arr) { let min = Math.min(...arr); let max = Math.max(...arr); let oddNumbers = []; for (let i = min; i !arr.includes(x)); return res } console.log(missingOddNumbers(input));
@nileshnilu79022 жыл бұрын
Make more video like this very her.
@ankurpandey31522 жыл бұрын
Wow nice interview
@unboxtheboxed-ox3cp Жыл бұрын
function oddcalc(arr){ for(let i=0;i2){ missing = (arr[i]+arr[i+1])/2; return missing; } } } let val =oddcalc([5, 7, 9, 11, 13, 15, 19]); console.log(val)
@FreeTrial0315 Жыл бұрын
const arr =[5,7,9,11,15,17,19,23]; const data = new Set(arr) for(i=5; i
@laylahashmi4234 Жыл бұрын
function missingOddNum(arr) { let completeArr = [arr[0]]; for (let i = 0; i < arr.length; i++) { let value = completeArr[i] + 2; completeArr.push(value) } return completeArr.filter((num) => !arr.includes(num)) }
@shailenderjaiswal16852 жыл бұрын
why can we not use binary search here sir
@coderdost2 жыл бұрын
binary search works when you know what to search for.. and divide the search space into half... and so on. Here we don't know where the missing number will occur. so dividing will not help us Optimize. both the left and right half of the divided part will be searched again.. If anyone has a better approach, can comment.
@shailenderjaiswal16852 жыл бұрын
@@coderdost understood sir👍
@CryptoAirdropnow2 жыл бұрын
is there any way to give a mock interview with you
@coderdost2 жыл бұрын
you can email. at email given on about page.
@uditkhandelwal63307 ай бұрын
USING BINARY SEARCH -> const input1 = [5, 7, 11, 13, 15, 17, 19]; const input2 = [19, 17, 13, 11, 9, 7, 5]; const findMissingOddNumber = (arr) => { let l = 0; let r = arr.length - 1; let d; if(arr[l]
@stefumies5 ай бұрын
const missingNumber = input.reduce((ac,c,i,a) => i == 0 ? a : ((c - a[i-1])> 2) ? a[i-1] + 2 : ac ,null)
@teentexh Жыл бұрын
let array=[5,7,9,11,15,17]; let value=array[0]; for(let a of array){ if(a===value){ value+=2 ; }else{ console.log(value); break; } }
@shailenderjaiswal16852 жыл бұрын
sir please 🙏 make react interviews also
@coderdost2 жыл бұрын
Have you seen all old ones react interviews??
@immdipu2 жыл бұрын
function missingOdd(array){ let firstDigit = array[0]; let missingDigit = null; while(missingDigit === null){ if(firstDigit % 2 !== 0){ if(!array.includes(firstDigit)){ missingDigit = firstDigit; return missingDigit; } } firstDigit++; }
@coderdost2 жыл бұрын
Why we will need to check -> firstDigit %2, as all are odd only. and will have mod as 1.
@immdipu2 жыл бұрын
@@coderdost all are not odd. firstDigit will increase by one each time the while loop runs. so it means the first time while loop runs firstDigit will be 5 and second time the while loop run the value of firstDigit will increase by one i.e 6 . 6 is not a odd number so that why we need firstDigit%2
@coderdost2 жыл бұрын
@@immdipu OK, I think you can optimize by reducing the iteration and skipping the even increments totally
@yashvantsharma76792 жыл бұрын
Sir plz reactjs developer 1.5 year experience interviews question share kijiye... Plz
@coderdost2 жыл бұрын
There is 1 experienced person interview also in this series
@coderdost2 жыл бұрын
More will come after that
@yashvantsharma76792 жыл бұрын
@@coderdost ok thankyou
@aryankhandelwal152 жыл бұрын
Sir, pls raise the qus diff
@coderdost2 жыл бұрын
Need candidates who want to have more difficult questions.
@a.spragadeeshbalaji2917 Жыл бұрын
//FIND THE MISSING ODD NUMBER WITHIN THE RANGE SPECIFIED IN THE ARRAY const input = [5,7,9,11,15,17]; for(let i=input[0]; i
@rajulorencemurmu3838 Жыл бұрын
My approach is:- Since they all are odd then what we can do is create an array and store all odd elements in that array like 5 to 17 then we can compare them both using loops if the first element of new array does not match to the first element of previous array then we print that.
@coderdost Жыл бұрын
but creating another array is extra effort. it will increase the space complexity. you can use same logic on original array and check if next element is not the next Odd number ( previous + 2)
@mitesh51892 жыл бұрын
const b = [5,7,11,13,17] function missOdd(arr) { let i = arr[0]; let a =0 while(true){ if(arr[a]===i){ i +=2; a++; } else{ console.log(i); break; } } } missOdd(b);
@coderdost2 жыл бұрын
simple and effective. using 'a' as index and 'i' as element is only distracting part.
@584_tyit_rohitghadge95 ай бұрын
let arr=[1,3,9,11,15,17]; let emp=[]; let missingvalue=(arr)=>{ let min=Math.min(...arr); let max=Math.max(...arr); for(let i=min;i
@payalkothari4862 Жыл бұрын
let missingNumber; for (let i = input[0]; i
@zimbasardhara3450 Жыл бұрын
let data =[1,3,5,7,9,11,15,17,19,21] let data2=[]; for(let i=0;i