anjalimutha10
BAN USERdef merge(nums1, m, nums2, n)
puts nums1[m..m+n] = nums2
puts nums1.sort!
end
nums1 = [1,2,3,0,0,0]
nums2 = [2,5,6]
m = 3
n = 3
array2 = merge(nums1, m, nums2, n)
def move_zeroes(nums)
n = nums.length
count = 0
for i in (0...n)
if nums[i]!=0
nums[count]=nums[i]
count+=1
end
end
while count < n
nums[count]=0
count+=1
end
end
nums = [0,1,0,3,12]
move_zeroes(nums)
print nums
array = [5,3,4,6,7,5,3,2,1]
hash = Hash.new(0)
array.each do |x|
hash[x]+=1
end
hash.each do |x,y|
if y > 1
puts "#{x} appears #{y} times"
end
end
s1 = "amazon"
s2 = s1.chars.take(2).join
s3 = s1[2..-1]
s4 = s3 << s2
s5 = "azonam"
if s4 == s5
puts true
else
puts false
end
Ruby
s1 = "amazon"
s2 = s1.chars.take(2).join
s3 = s1[2..-1]
puts s3 << s2
array =[-1, 6, 9, -4, -10, -9, 8, 8, 4]
def sort_positive_negative(array)
pos_arr = []
neg_arr = []
while array.size > 0
if array.first >= 0
pos_arr << array.shift
else
neg_arr << array.shift
end
end
until pos_arr.size == 0 && neg_arr.size == 0
array << pos_arr.shift if pos_arr.size > 0
array << neg_arr.shift if neg_arr.size > 0
end
return array
end
res = sort_positive_negative(array)
puts res
Ruby
str = "Happy%Christmas%%&&&A@New^^$#@"
str2 = str.scan /[[:word:]]+/
puts str2
Ruby: Solution 1 using array
Input
a=[11,22,33,22,44]
a.uniq.each do |k,v|
v = a.count(k)
puts "#{k} appears #{v} times"
end
Output:
11 appears 1 times
22 appears 2 times
33 appears 1 times
44 appears 1 times
Solution 2 using Hash
a=[11,22,33,22,44]
# make the hash default to 0 so that += will work correctly
b = Hash.new(0)
# iterate over the array, counting duplicate entries
a.each do |v|
b[v] += 1
end
b.each do |k, v|
puts "#{k} appears #{v} times"
end
Amazon search functionality can be tested in following ways:
UI Testing
Functional Testing
Boundary Value Testing
Data Correctness Tests
Load and Stress Tests
Search relevance
Search advanced features
Search Box Test Cases
* Does the search box shows search page without any search query?
* What does search page shows if you enter nothing in search box and hit enter or press finder icon?
* What does search box does if the search query is not entered?
* Check if the search box is present or not.
* Check if the search box length is as per the specification.
* Check the length of the query to be added into the search box.
* Check the characters allowed to be entered into the search box.
* Does the search box presents auto suggestions when the query is being typed?
* Does the search box offers typo corrections for the search query?
* Does the search box allows searching with incorrect spellings?
* Check if the amazon page offers default focus at search box or not.
Search History Test Cases
* Does the search history page keeps history of your previously searched products on amazon?
* Does the search history page offers you option to hide the history of previously searched products?
* Does the search history page offers matching products related to the search keywords?
* Does the search history page allows you to disable tracking the search completely?
* Does disabling search history makes any change to the suggestions offered by search-box?
* Does disabling search history stops certain products being featured?
* Does disabling search history reverts back to the default setting in a new session?
* Search Page Test Cases
Please check out the search sidebar for the test cases.
sidebar search test case
Does the search page categorizes more options to filter product search?
Does the search page offers price sorting from low to high?
Does the search page offers price sorting based on sales rank?
Does the search page offers price sorting as per the popularity?
Does the search page offers price sorting as per the brands?
Does the search page offers product sorting as per reviews?
Does the search page offers product sorting as per the category?
Does the search page offers product sorting as per the condition of the product? (New, old, refurbished)
Does the search page offers product sorting as per the shipping options?
Does the search page offers sorting as per the sellers?
Does the search page excludes not available products?
Does the search page offers alternative if the searched product is not available?
Responsive Test Cases
Does the search box appears on mobile?
Does the search box suggestions appear on mobile or tablet?
Does the search box offers category selector on mobile or tablet?
Does the search box offers drop-down menu on smaller devices?
a = [1,3,5,7,9,11,15,17,19]
- anjalimutha10 February 22, 2021b = Array.new
l = a.length
n = 3
start=0
endv=n
(0...l).step(n) do |i|
for j in (endv-1).downto(start)
b << a[j]
end
start= start + n
endv = endv + n
end
print b