def moveNumber(nums, target): pos = 0 for num in nums: if num != target: nums[pos] = num pos += 1 for i in range(pos, len(nums)): nums[i] = target Time : O(n), Space O(1), In place movement by maintaining the relative order of elements.
@sheikhkevinbnujameskev77043 жыл бұрын
arr = [6,1,6,8,10,4,15,6,3,4,6] def ea(array,t): for i in range(0,len(array)): if array[i]==t: array.append(array[i]) array.pop(i) print(array) ea(arr,6) Time complexity == O(n) Space complexity ==O(1)
@sankaranarayananp84073 жыл бұрын
In C Programming, #include #include void main() { int size, i, j, target; int* arr; printf("Enter the size of an array: "); scanf("%d",&size); arr = (int*)calloc(size, sizeof(int)); if(arr==NULL) { printf("Out of memory !!"); } else { printf("Enter the elements: "); for(i=0; i
@rishikesh27573 жыл бұрын
Shaheen nice programming + comedy aanallo.njan parayenda kaaryamilla but full crossroads team poli aanu.
@BrototypeMalayalam3 жыл бұрын
thanks man ♥️
@faisalerakottil6757 ай бұрын
answer of the last Question in Dart List moveFivesToEnd(List arr) { List nonFives = []; List fives = []; for (int element in arr) { if (element == 5) { fives.add(element); } else { nonFives.add(element); } } return nonFives.followedBy(fives).toList(); } void main() { List arr = [1, 2, 5, 3, 5, 2, 6, 5, 7, 8, 5]; List modifiedArr = moveFivesToEnd(arr); print(modifiedArr); }
Oru Doubt... num.contain() oru function alle... so inside that function oru comparison tanne lle nadakunne.. Apo aa function matram O(n) varulle?. Total program nn O(n^2) ??
@jelanmathewjames25792 жыл бұрын
solution with O(n)T and O(1)S using j and i variables. for loop decrement # function def arrayproblems(array,target): # i and j variables having position of last element i = j = len(array)-1 for i in range(i,-1,-1): # checking all elements if array[i]== target: array[i],array[j] = array[j],array[i] j -= 1 array = [1,2,3,1,2,4,2,3,5,3,2,5,3,5,3,1,6,4,5,4,3,1,6,5,4,3,1,5] target = 3 print("Given Array:",array) print("Given Target",target) arrayproblems(array,target) print("Answer",array)
@hasanulbanna71242 жыл бұрын
def rearrange(ls,target): for i in range (0,len(ls)): if ls[i]==target: ls.append(ls[i]) del ls[i] return ls Space complexity = O(1) Time complexity = O(n)
@Raihan-Rahoof Жыл бұрын
can we use more inbuilt function
@amaljs41682 жыл бұрын
def arrange(array,number): j=len(array)-1 if array[j]==number: j-=1 for i in range(0,len(array)-1): if j>=i: if array[i]==number: array[j],array[i]=array[i],array[j] j-=1 return print(array) arrange([1,3,5,2,5,1,8,14,1],1) Answer : [14, 3, 5, 2, 5, 8, 1, 1, 1]
@shamseerpv86473 жыл бұрын
. Android studio , fuleter ഇവ windows 10 ആണോ ? Ubandu വില്യാണോ ? ഉപയോഗിക്കാൻ നല്ലത്
@arunthomas59893 жыл бұрын
sir ee Hackingum codingum tamelulla bendam enta
@rishikesh27573 жыл бұрын
coders are not hackers but hackers are probably coders too
@vinayakvishnu89535 ай бұрын
Thanks❤
@raishadn10362 жыл бұрын
Array yilee elements print cheyyaan for loop use cheyyunnund... But athinte O(n) enthaa edukkaathath? Pls reply
@raishadn10362 жыл бұрын
Aarenkiklm reply tharoo?
@mohammedsafvan63442 жыл бұрын
@@raishadn1036 Aaa bhagham java specific aaanennu thonunnu python il okke nerittu array print cheyyam
@vishnuprasad87023 жыл бұрын
Node solution First Method => const twoNumberSum = (array, target) => { for (let i = 0; i < array.length - 1; i++) { for (let j = i + 1; j < array.length; j++) { if (array[i] + array[j] === target) return [array[i], array[j]]; } } return null; } const array = [6, 5, 4, 3, 9, 8, 0]; const target = 10; console.log(twoNumberSum(array, target)); Second Method=> const twoNumberSum = (array, target) => { let set = new Set(); for (let i = 0; i < array.length; i++) { let number = array[i]; let match = target - number; if (set.has(match)) { return [number, match]; } else { set.add(number); } } return null; } const array = [6, 5, 4, 3, 9, 8, 0]; const target = 10; console.log(twoNumberSum(array, target));
@muhammednavas-yd1ut2 жыл бұрын
thanks bro
@udaysankar94113 жыл бұрын
' déjà vu ' പറ്റി കേട്ടിട്ടുണ്ടോ ഈ ക്ലാസ് കണ്ടപ്പോള് എനിക്ക് അത് തോന്നി
@BrototypeMalayalam3 жыл бұрын
ആഹാ! dejavu തോന്നിക്കാൻ ഇത് മുന്നേ നീ പഠിച്ചോണ്ടാവും 😄
@krayshellinc20153 жыл бұрын
A glitch in the matrix or someone else is trying to communicate with you from another universe
@aneesh.augustine Жыл бұрын
java script time and space complexity o(1) let arr = [6, 1, 6, 8, 10, 4, 15, 6, 3, 9, 6]; let target = 6; console.log(arr); function sort(arr, target) { arrLength = arr.length; for (let i = 0; i < arrLength; i++) { if (arr[i] == target) { let val = arr[i]; arr.push(val); arr.splice(i, 1); } } return arr; } console.log(sort(arr, target));
@rebinnajeeb9293 Жыл бұрын
100k challenge padichett ee series padichaal eluppano?I mean python il full cheyyunnathano nallath or?...
@BrototypeMalayalam Жыл бұрын
ithil cheyyunath pole cheytholu
@khaderafsal2 жыл бұрын
public static void swap(int[] array, int target){ for(int i=0;ii;j--){ if(array[j]!=target ){ int temp=array[i]; array[i]=array[j]; array[j]=temp; } } } } for(int i=0;i< array.length;i++){ System.out.println(array[i]); } } }
@s4studios3793 жыл бұрын
Array out of bound exception ennu kaanikunnu result ethiley frst twoNumberSum problem cheympol.
function same(arr, t) { let normalV = []; let sameV = []; let newArr; for (let i = 0; i < arr.length; i++) { if (arr[i] === t) { sameV.push(arr[i]); } else { normalV.push(arr[i]); } } return (newArr = [...normalV, ...sameV]); } const result = same([3, 5, 3, 4, 7, 3, 9, 3], 3); console.log(result); The time complexity and space complexity are O(n).
@ABINBIJU6 ай бұрын
for (int i=0;i
@adarshkm85033 жыл бұрын
ithinte pseudo code paranju tharuo?
@adhilfouzi5511 Жыл бұрын
Dart solution List twoNumberSum(List array, int target) { array.toSet(); for (int i = 0; i < array.length; i++) { int num = array[i]; int match = target - num; if (array.contains(match)) { return [num, match]; } else { array.add(num); } } return []; } void main() { List array = [6, 5, 7, 9, 4, 0, 2]; int target = 10; List result = twoNumberSum(array, target); for (int i = 0; i < result.length; i++) { print(result[i]); } }
@vajidnalakath80602 жыл бұрын
public class Sample { public static int[] SwaptoEnd(int array[],int target) { for(int j=array.length-1;j>0;j--) { if(array[j]!=target) { for(int i=0;i
@jijomrrover3785 Жыл бұрын
let arr=[2,3,5,6,4,6,3,8]; let target=6; function fun(target,arr){ let limit=arr.length-1 for(let i=0;i
@theophinjohnson82343 жыл бұрын
Time = O(n)T space = O(1)S public class ArrayProblems { public static int[] moveValueToEnd(int [] array) { int length = array.length; int i=0,temp,j=length-1; while(i
@fathimasherin20955 ай бұрын
using dart class Solution { List moveSix(List nums, int target) { int n=nums.length-1; int temp=0; int i=0; while(i
@agpskalaparipaadeex7077 Жыл бұрын
public static int[] sol(int[] arr,int target){ int i=0,j=arr.length-1; while(i
@orzogaming42853 жыл бұрын
From brirtish academy Koyilandy 😅💥🔥 powli presentation 🔥😍
@BrototypeMalayalam3 жыл бұрын
thankyou thankyou ♥️
@fsocietynauran86053 жыл бұрын
Day 2, njan eddaum ethittunde. Pinne aaa introill paranja sambavam indallo ( engakke eth inn anne, njangakk eth nale anne ) Ath njan oru 4 pravisham rewind cheyth nokki enittum manasilayella😂
@MrAmeer273 жыл бұрын
Nale nnu parayum innale akumo?
@BrototypeMalayalam3 жыл бұрын
illa illa 🤣🤣🤣
@avishithpm17123 жыл бұрын
ipo oru kariyam manasill aayii ee pani athra eluppam alla.....10 manikk kanda vido ya ithu vare answer complete chiyan pattiyillaa..python ill simple aayii appendum remove vum vechu chiyaam bt..using i and j in for loop is tricky...
target - arrayil illa first number cheythal kittuna number aa arayil indo check cheytha pore . For example 10-6 =4 appo aa arayil enji 4 indo nokkiya pore
@jainibrm13 жыл бұрын
ആദ്യം 6 വന്നാൽ പെട്ടന്ന് കിട്ടും 5 വന്നാലോ. മൊത്തം array search ചെയേണ്ടി വരും time complexity koodum.
@BrototypeMalayalam3 жыл бұрын
array il number undo enn check cheyyunnath O(n) time comlexity varum. so ooro numberinum match check cheyyumbol o(n^2) varum. Ee method aanu 2 for loop ittu 1st cheythathu. Second method il set il indo enn nokan o(1) time complexity aanu. so total o(n) varullu.
@parthivk90753 жыл бұрын
@@BrototypeMalayalam hmm
@ummarfarooquk35143 жыл бұрын
Macchane idh powlikkum 😍💯
@BrototypeMalayalam3 жыл бұрын
polichadakkanam 🔥
@jrmations75573 жыл бұрын
Sir ഞാൻ ഇപ്പൊൾ പ്ലസ് two aan പഠിക്കുന്നത്.njn കണക്കിൽ ഒരു ആവറേജ് സ്റ്റുഡൻ്റ് ആണ്.എനിക്ക് computer science പഠിക്കാൻ കഴിയുമോ...? ഏത് തരം കണക്കാണ് കമ്പ്യൂട്ടർ സയൻസിൽ പഠിക്കുന്നത്? കമ്പ്യൂട്ടർ സയൻസിൽ കണക്കിൻ്റെ role എന്താണ്.?
@jrmations75573 жыл бұрын
Coding cheyyumbol maths important aano
@jrmations75573 жыл бұрын
Sir,Enthanu problem solving skills enn kond udeshikkunnath..
@JohnDoe-to8vr11 ай бұрын
#InJavaScript function moveTargetToEnd(arr, target) { let rightPointer = arr.length-1; for (let i = 0; i
@keraleeyan11 ай бұрын
Bro ithokke padichal job kittumo ??
@BrototypeMalayalam11 ай бұрын
Ith veruthe padichathu kond job kitilla proper aay padich skill set cheythaal nalla joblekk keraam, for more help connect with our team
@JohnDoe-to8vr11 ай бұрын
@@keraleeyan serious ayi padichal kittum
@keraleeyan11 ай бұрын
@@JohnDoe-to8vr c program enikku kurachu ariyam , enikku enthokke cheyyan pattum c coding use cheythu ??? . Projects cheythalalle job kittoo !! Atha chothiche ?? . C coding njan collagil adichittundu but covid timil aayathinal theory mathram aayirunnu !!
@sandeepkarippayil92823 жыл бұрын
Length -1 cheyendallo
@albinjijo33293 жыл бұрын
Video eppo varum
@BrototypeMalayalam3 жыл бұрын
soon 🔜
@albinjijo33293 жыл бұрын
@@BrototypeMalayalam inn varo, wait cheyyano
@BrototypeMalayalam3 жыл бұрын
Innilla
@vishnuprasad87023 жыл бұрын
Solution in javascript //--First Method--// //--Complexity O(n2)T, O(1)S--// const sameNumber = (array, target) => { for (j = array.length -1; j > 0; j--) { if(array[j] !== target) { for (i = 0; i { for (i = array.length - 1; i >=0 ; i--) { if(array[i] === target) { array.splice(i, 1) array.push(target) } } return array; } const array = [6, 1, 6, 8, 10, 4, 15, 6, 3, 9, 6]; const target = 6; console.log(sameNumber(array, target));
@BroForYou3 жыл бұрын
In Video ella Bro
@BrototypeMalayalam3 жыл бұрын
no, next day 👍🏼
@syamilycm72473 жыл бұрын
Anyone knows about the history of neural nets in computing?
@nsnizam65963 жыл бұрын
ഞാനേ 100k kanditt vera ,allathe ith മുന്നോട്ട് കൊണ്ടൊവ്വൻ പറ്റില്ല..
@BrototypeMalayalam3 жыл бұрын
എന്നാ വേഗം വാ, നീ ഒന്ന് വിചാരിച്ചാൽ 5 ദിവസം മതി 💪🏼
@nsnizam65963 жыл бұрын
@@BrototypeMalayalam 👍🏻
@TOP10_cybro3 жыл бұрын
Super
@BrototypeMalayalam3 жыл бұрын
thanks
@gokulkrishna32423 жыл бұрын
Korach delay varunundallo Video 2 divasay illa Waiting arnu
@BrototypeMalayalam3 жыл бұрын
need to complete editing and final touches, thats why! we will be back soon 🔥
@prathyupkpk7333 жыл бұрын
72k subscribers💙💚💚💙😍😍😍😍😍
@BrototypeMalayalam3 жыл бұрын
and far more to go 🤩🤩🤩
@shahaludheenk15333 жыл бұрын
Nginx tutorial ennn indavaa
@BrototypeMalayalam3 жыл бұрын
within 2 weeks 🙌🏼
@sudo-mon2848 Жыл бұрын
function arrange_array(array , target) { let i = 0; let j = (array.length - 1); while(i
@safwankanniyath76943 жыл бұрын
adipoli
@redstoneninja33753 жыл бұрын
Crossroads ❤
@shad0163 жыл бұрын
Kore kaalayallo kandittu??
@BrototypeMalayalam3 жыл бұрын
athe, pettennu thanne varam 👍🏼
@rajaduraii84993 жыл бұрын
Hello Crossroads Team... your student Abilash (Peter) has been sending me your KZbin link daily... he ask me to comment his name in every link..🔥🔥🔥 yours Obediently with love PARTNER GUYZ
@rayyanrasheed80103 жыл бұрын
2:21 ashaante tactical moves 19:08 sonu cheythappol aayirunnu chirikkan othiri ullath um pinne nalla rasam ullath um 21:38 appol kittunna oru sukam undello ha oru valiya manasukamaa 21:58 patthu thalaya thani ravanan like Dillu bhai. Athinte pinnile secret obviously nikhil sir thanne alle randaludeum mentor Uff 29:25 ind ennnu sonu parangappol aaki aayirunnu puthiya pillark freedom kodukkunath koodipooyo 32:13 ashante oro tactical moves Uff
@BrototypeMalayalam3 жыл бұрын
അതെ അതിബുദ്ധിപരമായ നീക്കങ്ങൾ 😜 ആഹ് അതും ഒരു കാലം 😋 പിന്നല്ല, ഇരട്ട പെറ്റ സുഖം 😂 അത് പിന്നെ അത്രയേ ഉള്ളു 🤞🏼 പുതിയ പിള്ളേർക്ക് സ്വല്പം freedom കൊടുക്കുന്ന ഒരു modern family ആണ് നമ്മുടേത് 😎 വീണ്ടും വീണ്ടും തന്ത്രപരമായ നീക്കങ്ങൾ 😂
@rayyanrasheed80103 жыл бұрын
@@BrototypeMalayalam Uff
@sanalls3 жыл бұрын
Time complexity: O(n) Space complexity: O(n) public class Arrange{ public static int[] arrange (int[] array, int target){ int i = 0; int j = array.length-1; while(i
@sanalls3 жыл бұрын
janguage : java
@musthafakoppam2 жыл бұрын
Bro... Last value 6 allaathath koduthal result marunnundd..... pls check...
@adnanajju60253 жыл бұрын
I got
@adnanajju60253 жыл бұрын
O (n)t O (1)s
@raviganeshm96063 жыл бұрын
public class Main { public static int[] rearrangeArray(int[] arr, int num) { int i=0, j=arr.length-1; while(i < j ){ if(arr[i] == num) { if(arr[j] == num) { j-=1; } else { arr[i] += arr[j]; arr[j] = arr[i] - arr[j]; arr[i] = arr[i] - arr[j]; i++; j--; } } else { i++; } } return arr; } public static void main(String[] args) { int[] arr = {6,1,6,7,8,4,5,6}; int num = 6; int[] res = rearrangeArray(arr, num); for(int k=0; k
@raviganeshm96063 жыл бұрын
a = [6,4,6,7,8,9,4,5,6] b = 6 for i in range(len(a)): if a[i] == b: a.append(a.pop(i)) print(a) #Time complexity O(n) #Space complexity O(1)
@shaheenhyder82313 жыл бұрын
Congragulations you are selected as the winner. Please share your mobile number and email Id for further communication
@BrototypeMalayalam3 жыл бұрын
you can share your details to 7034395811 👍🏼
@Lofi_Night_YT2 жыл бұрын
How did you get this code
@mrbmalayalam2 жыл бұрын
//dart [not for cash prize] void main() { var s= result(); print(s); } result(){ List arr = [6,6,6,8,10,4,15,6,3,4,1]; int target=6; int j=arr.length-1; for(int i=0;i< arr.length;i++) { if(arr[j]==target) { j--; } if(arr[i]==target) { int swap=arr[j]; arr[j]=arr[i]; arr[i]=swap; j--; } if(i==j) { break; } } return arr; }
@MrAmeer273 жыл бұрын
👍👍
@namithajoby44903 жыл бұрын
🔥
@shawnbeans73893 жыл бұрын
ccna tutorial eduva
@BrototypeMalayalam3 жыл бұрын
we can think about it 👍🏼
@SanjaySanjayxcode7 ай бұрын
Const read = require("readline-sync") userInput=read.question("enter choice") Let arr=[8,16,32,9,10,4] for(i=0;ii;j--){ if(arr[i]===parseInt(val)){ let tempval=arr[i] arr[i]=arr[j] arr[j]=tempval } } }
@uvvaishnav19983 жыл бұрын
Entha video eedan thamasam?🤔
@BrototypeMalayalam3 жыл бұрын
few more editing works to complete, thats why 👍🏼
@shamilussainc64563 жыл бұрын
public class ArraySample2 { public static void main(String[] args){ int[] array = new int[]{6,1,6,10,4,15,6,3,9,6}; System.out.print("Array before arrangement : "); for (int item: array) { System.out.print(item+" "); } int i=0,j=array.length-1; while (i != j){ if (array[i] == 6){ if(array[j]!=6){ int temp = array[j]; array[j] = array[i]; array[i] = temp; i++; } j--; }else { i++; } } System.out.print(" Array after arrangement : "); for (int item: array) { System.out.print(item+" "); } } } please comment your opinion about this one.
@solotravel1453 жыл бұрын
😂
@safvanp16802 жыл бұрын
put ( j - - ) in else block
@jainibrm13 жыл бұрын
👌🌹
@sankee6th Жыл бұрын
bro intro bgm 1.5x ill set ann kekkann normal ullathinekaal😁
@GADESTO3 жыл бұрын
100k bayngara sambavamalle 🤩
@BrototypeMalayalam3 жыл бұрын
pinnella! athaan ellathintem ustad 🔥
@abhishekballullayak24943 жыл бұрын
public class ArrayElementShift { public static int[] shiftToEnd( int[] array,int target) { int i; int j=array.length-1; int temp; for(i=0; i
@dr_strange.61653 жыл бұрын
🔥🔥🔥
@shincyraffy47623 жыл бұрын
public class array2 { public static int[] placeAtEnd(int[] arr, int val) { int temp; int i=0,j=arr.length-1; while(i
@uv19063 жыл бұрын
❤❤❤❤
@BrototypeMalayalam3 жыл бұрын
much love 💖
@blank-xtx11 ай бұрын
public class Sample{ public static int[] result(int[] array, int target){ int temp=0; int i=0; int j=array.length-1; while(j>=i){ if(array[i] == target && array[i] == array[j]){ j--; }else if(array[i] != target) i++; else if(array[i]==target && array[i]!=array[j]){ temp = array[j]; array[j] = array[i]; array[i] = temp; i++; j--; } } return array; } public static void main(String[] args){ int[] array = {6,1,6,8,10,4,15,6,3,9,6}; int target = 6; int[] display = result(array, target); for(int i=0;i
@BrototypeMalayalam11 ай бұрын
Please you the telegram groups for Doubt clearing sections.
@suhailadrsseri7883 жыл бұрын
shaheen thakarkkanallo
@BrototypeMalayalam3 жыл бұрын
avan polikkatte 🔥
@vishnu.s_3 жыл бұрын
ഇന്നത്തെ pratical section പൊളിച്ചു.പക്ഷെ പാവം array അതിനെ വെച്ച് ഇങ്ങനെ ഒക്കെ ചെയ്യണോ.അവസാനത്തെ program queue ഇന്റെ insertion പോലെ ചെയാം Class sort{ public static void main (String[] ar){ int[25] a={6,1,6,8,10,4,15,6,3,9,6}; int e=6; int rear=a.length-1; for(int i=0;i
@lucifer-eo6bw2 жыл бұрын
Broo ithu pola sambhavam pettannu pidi kittan valloom trick ondengil paranu tharo
@lucifer-eo6bw2 жыл бұрын
Question manasilaayii paksha logic katthunilla 🤔🤔
@athul50412 жыл бұрын
@@lucifer-eo6bw Kure logic workout cheythu nokkiyal kittum. It grows in time.
@GOODIESS3 жыл бұрын
Pever🔥🔥
@jithinp84413 жыл бұрын
1.25x set annnn😁
@arunkrish112 ай бұрын
JAVA package sameNumberAtEnd; import java.util.Arrays; public class SameNumberAtEnd { public static int[] sameNumerAtEnd(int[] array, int sameNum) { int j = array.length-1; for (int i = 0; i < j; i++ ) { if (array[j] == sameNum) { j = j - 1; } if (array[i] == sameNum) { int temp = array[j]; array[j] = sameNum; array[i] = temp; } } return array; } public static void main(String[] args) { int[] array = { 2, 6, 5, -4, 6, 8, 11, 6, 1, 6 }; int sameNum = 6; int[] result = sameNumerAtEnd(array, sameNum); System.out.print(Arrays.toString(result)); } } OUTPUT: [2, 1, 5, -4, 11, 8, 6, 6, 6, 6]
# in python # time complexity: O(n) | 1 for loop # space complexity: O(1) | no extra space def arrayinterchangenumtolast(array,target): i = j = len(array)-1 for i in range(i,-1,-1): if array[i] == target: array[i],array[j] = array[j],array[i] j -= 1 array = [23,48,45,23,69,45,63,23,89,23,82,23,97,23,62,23,45,56,23,89] target = 23 arrayinterchangenumtolast(array,target) print("Array:",array) print("Target",target) print("OutPur",array)
@_dikshitm77153 жыл бұрын
2 aalum ore wave length aaa....othupokumm 😂😇
@BrototypeMalayalam3 жыл бұрын
haha!! athaan vendath 🙌🏼
@ameenulhaseeb38993 жыл бұрын
public class Main { public static int [] moveCommonElement(int [] inputArr,int target) { int j=inputArr.length-1; for(int i=0;i< inputArr.length;i++) { if(inputArr[j]==target) { j--; } if(inputArr[i]==target) { int swap=inputArr[j]; inputArr[j]=inputArr[i]; inputArr[i]=swap; j--; } if(i==j) { break; } } return inputArr; } public static void main(String args[]) { int [] inputArr = {6,8,9,6,4,6,8,7,6,8,3,6}; int target=6; int [] result=moveCommonElement(inputArr,target); for(int i=0;i
@rahula66052 жыл бұрын
thankyou bro 🥰🥰
@robincr95333 жыл бұрын
Changayi mare ningale kanan illa lo
@BrototypeMalayalam3 жыл бұрын
മച്ചാനെ.. late aayalum, latesta varum 😘
@CA-bg3im4 ай бұрын
public class ArrayMovetoEnd { public static int[] rearrange(int[] array,int target) { int i=0, j=array.length-1; int temp; while(i
@aromalhere3 жыл бұрын
//Time complexity: O(N), //Space complexity: O(1) public class Main{ static int[] sortArray(int []array, int key) { int i = 0; int j = array.length - 1; while (i < j) { while (i < j && array[j] == key) j--; if (array[i] == key) swap(array, i, j); i++; } return array; } static int[] swap(int []arr, int i, int j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; return arr; } public static void main(String[] args) { int []arr = { 6,1,6,8,10,4,15,6,3,9,6 }; int Key = 6; int []res = sortArray(arr, Key); for(int i = 0; i < arr.length; i++) System.out.print(res[i] + " "); } } //Aromal S //aromalsanthosh@protonmail.com //+917902293783
@bibinbabu27343 жыл бұрын
I think the time complexity is 0(n^2)
@bibinbabu27343 жыл бұрын
Use OK two while loop
@BroForYou3 жыл бұрын
Anth patti Brothers kora ayalo kandit
@BrototypeMalayalam3 жыл бұрын
ഒന്ന് rest എടുത്തതാ! പെട്ടെന്ന് തന്നെ വരും 🔥
@hishamahammmedkm19363 жыл бұрын
where is the tamil Guy
@BrototypeMalayalam3 жыл бұрын
അവന്റെ സമയം ആവുമ്പോൾ അവൻ വരും 🔥🤩
@radz1153 жыл бұрын
Time Complexity : O(n) Space Complexity : O(1) public class Main { public static int[] SwapToEnd(int[] Array,int target) { int j = Array.length - 1; for (int i = 0; i < Array.length; i++) { if (Array[i] == target && i < (j - 1)) { while (Array[j] == target && i < (j - 1)) { j--; } int temp = Array[j]; Array[j] = Array[i]; Array[i] = temp; } } return Array; } public static void main(String[] args) { int[] Array={6,1,6,8,10,4,15,6,3,9,6}; int target=6; System.out.print("Before : "); for(int i=0;i
@hidashsaidu84663 жыл бұрын
First
@SidhikTanalur3 жыл бұрын
var six = 6; var numbers = [6,1,6,8,10,4,15,6,3,9,6]; var new_nums = []; for (var i = 0; i < numbers.length; i++) { if (numbers[i] == six) { new_nums.push(numbers[i]); } else { new_nums.unshift(numbers[i]); } } numbers = new_nums; console.log(JSON.stringify(numbers));
@tojyjv7483 жыл бұрын
എഴുതുന്നതെല്ലാം ചരിഞ്ഞു പോകുന്നു. വായിക്കാൻ പ്രയാസം. രണ്ടുപേരും എഴുന്നേറ്റ് നിന്ന് സംസാരിച്ചാൽ എഴുതുന്നത് നേരെ ആകും. സാധാരണ എല്ലാവരും ക്ലാസ്സ് എടുക്കുന്നത് എഴുന്നേറ്റ് നിന്നിട്ട് ആണല്ലോ.
@snehasunny65852 жыл бұрын
public class Main { public static void main(String[] args) { int intArray[]={6,1,6,8,10,4,15,6,3,9,6}; int end=intArray.length-1; for(int i=0;i0){ if(intArray[i-1]==intArray[end]){ break; } } int temp = intArray[end]; intArray[end] = intArray[i]; intArray[i] = temp; } } System.out.println(Arrays.toString(intArray)); } } Time: O(n), Space O(1)
@SarinM3 жыл бұрын
Hack Club member spotted
@Apxc.4 ай бұрын
import java.util.*; public class Main{ public static void main(String[] args){ int[] a={6,1,6,8,10,15,6,3,9,6}; int selectedNumber = 6; moveSelectedNumberToEnd(a, selectedNumber); System.out.println(Arrays.toString(a)); } public static void moveSelectedNumberToEnd(int[] array,int selectedNumber){ int n =array.length; int j=0; //Transing the aarr for (int i =0; i