FirstLast6



Download 35,52 Kb.
bet2/3
Sana28.08.2021
Hajmi35,52 Kb.
#157697
1   2   3
Bog'liq
CodingBat Arrays

start and end numbers, return a new array containing the sequence of integers from start up to but not including end, so start=5 and end=10 yields {5, 6, 7, 8, 9}. The end number will be greater or equal to the start number. Note that a length-0 array is valid.

Yangi massiv uchun boshlang`ich va oxirgi qiymat berilgan shu sonlardan foydalanib o`sih tartibidgi ketma-ket sonlardan tashkil topgan massiv qaytarilsin. Bunda yangi massiv o`z ichiga oxirgi qiymatni olmaydi. Masalan boshlang`ich=5 va oxiri=10 sonlardan iborat massiv{5, 6, 7, 8, 9} ga teng.


fizzArray3(5, 10) → [5, 6, 7, 8, 9]


fizzArray3(11, 18) → [11, 12, 13, 14, 15, 16, 17]
fizzArray3(1, 3) → [1, 2]

Array-2 > shiftLeft 



Return an array that is "left shifted" by one -- so {6, 2, 5, 3} returns {2, 5, 3, 6}. You may modify and return the given array, or return a new array.

Berilgan massivdan yangi yoki o`zgartirilgan elementlari bitta chapga surilgan massiv qaytaring.Masalan, {6, 2, 5, 3} massividan {2, 5, 3, 6} massivi hosil bo`ladi.


shiftLeft([6, 2, 5, 3]) → [2, 5, 3, 6]


shiftLeft([1, 2]) → [2, 1]
shiftLeft([1]) → [1]

Array-2 > tenRun 



For each multiple of 10 in the given array, change all the values following it to be that multiple of 10, until encountering another multiple of 10. So {2, 10, 3, 4, 20, 5} yields {2, 10, 10, 10, 20, 20}.

Berilgan massivdagi barcha 10 ga karrali sonlardan keyin kelgan sonlarni keyingi karrali songachasini shu son bilan almashtiring.Masalan, {2, 10, 3, 4, 20, 5}dan {2, 10, 10, 10, 20, 20} massivi hosil bo`ladi.


tenRun([2, 10, 3, 4, 20, 5]) → [2, 10, 10, 10, 20, 20]


tenRun([10, 1, 20, 2]) → [10, 10, 20, 20]
tenRun([10, 1, 9, 20]) → [10, 10, 10, 20]

Array-2 > pre4 



Given a non-empty array of ints, return a new array containing the elements from the original array that come before the first 4 in the original array. The original array will contain at least one 4. Note that it is valid in java to create an array of length 0.

Butun sonlardan iborat bo`sh bo`lmagan massiv berilgan, birinchi kelgan 4 sonidan oldingi sonlardan tashkil topgan yangi massiv qaytarilsin. Berilgan massiv kamida bitta 4 raqamini o`z ichiga oladi.


pre4([1, 2, 4, 1]) → [1, 2]


pre4([3, 1, 4]) → [3, 1]
pre4([1, 4, 4]) → [1]

Array-2 > post4 



Given a non-empty array of ints, return a new array containing the elements from the original array that come after the last 4 in the original array. The original array will contain at least one 4. Note that it is valid in java to create an array of length 0.

Butun sonlardan iborat bo`sh bo`lmagan massiv berilgan, massivdagi oxirgi kelgan 4 raqamidan keying elementlardan tashkil topgan yangi massiv qaytaring. Berilgan massivda kamida bitta 4 raqami bo`ladi.


post4([2, 4, 1, 2]) → [1, 2]


post4([4, 1, 4, 2]) → [2]
post4([4, 4, 1, 2, 3]) → [1, 2, 3]

Array-2 > notAlone 



We'll say that an element in an array is "alone" if there are values before and after it, and those values are different from it. Return a version of the given array where every instance of the given value which is alone is replaced by whichever value to its left or right is larger.

Agar massivdagi berilgan elementdan oldingi va keyingi elementlar undan faqr qilsa berilgan element “yolg`iz” hisoblanadi. Berilgan element yolg`iz bo`lsa uni o`rniga o`zidan oldin va keyin kelgan elementlarning kattasi bilan almashtirilgan yangi massiv qaytaring.


notAlone([1, 2, 3], 2) → [1, 3, 3]


notAlone([1, 2, 3, 2, 5, 2], 2) → [1, 3, 3, 5, 5, 2]
notAlone([3, 4], 3) → [3, 4]

Array-2 > zeroFront 



Return an array that contains the exact same numbers as the given array, but rearranged so that all the zeros are grouped at the start of the array. The order of the non-zero numbers does not matter. So {1, 0, 0, 1} becomes {0 ,0, 1, 1}. You may modify and return the given array or make a new array.

Elementlari soni berilgan massiv elementlariga o`zaro teng bo`lgan va massivdagi barcha 0 lar massivning boshiga yig`ilgan yangi massiv qaytaring. 0 bo`lmagan elementlar o`rni joylashish o`rni ahamiyatga ega emas. Masalan, {1, 0, 0, 1} dan {0, 0, 1, 1} massivi hosil bo`ladi.


zeroFront([1, 0, 0, 1]) → [0, 0, 1, 1]


zeroFront([0, 1, 1, 0, 1]) → [0, 0, 1, 1, 1]
zeroFront([1, 0]) → [0, 1]

Array-2 > withoutTen 



Return a version of the given array where all the 10's have been removed. The remaining elements should shift left towards the start of the array as needed, and the empty spaces a the end of the array should be 0. So {1, 10, 10, 2} yields {1, 2, 0, 0}. You may modify and return the given array or make a new array.

Massivdagi barcha 10ga teng bo`lgan elementlarini o`chirib undan keyin kelgan elementlarni massiv boshiga qarab burish natijasida bo`sh qolgan elementlar o`rnini 0 bilan to`ldirilgan yangi massiv qaytaring.Masalan, {1, 10, 10, 2} massividan yangi{1,2, 0, 0} massiv hosil bo`ladi.


withoutTen([1, 10, 10, 2]) → [1, 2, 0, 0]


withoutTen([10, 2, 10]) → [2, 0, 0]
withoutTen([1, 99, 10]) → [1, 99, 0]

Array-2 > zeroMax 



Return a version of the given array where each zero value in the array is replaced by the largest odd value to the right of the zero in the array. If there is no odd value to the right of the zero, leave the zero as a zero.

Berilgan massivdagi barcha 0 larni undan o`ngda joylashgan eng katta toq son bilan almashtirilgan holdagi massiv qaytaring. Agar 0dan keyin boshqa raqam bo`lmasa 0sonini o`zini qoldiring.


zeroMax([0, 5, 0, 3]) → [5, 5, 3, 3]


zeroMax([0, 4, 0, 3]) → [3, 4, 3, 3]
zeroMax([0, 1, 0]) → [1, 1, 0]

Array-2 > evenOdd 
prev  |  next  |  chance

Return an array that contains the exact same numbers as the given array, but rearranged so that all the even numbers come before all the odd numbers. Other than that, the numbers can be in any order. You may modify and return the given array, or make a new array.

Elementlar soni berilgan massiv elementlarga teng bo`lgan va barcha juft elementlar toq elementlardan oldin kelgan yangi massiv qaytaring.Juft va toq elementlarning o`zaro joylashish o`rni ahamiyatli emas. Bunda siz massivni to`g`irlashingiz yoki yangi massiv qaytarishingiz mumkin.


evenOdd([1, 0, 1, 0, 0, 1, 1]) → [0, 0, 0, 1, 1, 1, 1]


evenOdd([3, 3, 2]) → [2, 3, 3]
evenOdd([2, 2, 2]) → [2, 2, 2]

Array-2 > fizzBuzz 
prev  |  next  |  chance

This is slightly more difficult version of the famous FizzBuzz problem which is sometimes given as a first problem for job interviews. (See also: FizzBuzz Code.) Consider the series of numbers beginning at 

Download 35,52 Kb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish