Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,160,804 members, 7,844,609 topics. Date: Thursday, 30 May 2024 at 01:17 AM

Weekend Algorithm Come In And Let's Brainstrom - Science/Technology - Nairaland

Nairaland Forum / Science/Technology / Weekend Algorithm Come In And Let's Brainstrom (368 Views)

Man Interrogates An Owl That Flew Into Home Over The Weekend (Pic/Video) / "The Algorithm Is Person!!", Cried The Google Engineer. / See Who Lives And Dies In GOT 8 According To AI Algorithm (2) (3) (4)

(1) (Reply) (Go Down)

Weekend Algorithm Come In And Let's Brainstrom by Yungmakaveli01(m): 8:20pm On Aug 05, 2023
Hello everyone I came up with a series titled the weekend algorithm.

It is a series that involves solving some programming questions on different scale of difficulty level and posting them every weekend on the iocode youtube channel, hence the reason for title (Weekend Algorithm).

see the link to the channel https://www.youtube.com/@IOCodes

I've a free course introduction to programming course coming up on the 14 of this month so do reach out to me on whatsapp @(zero7zero524seven2four06) me if you are interested.
Re: Weekend Algorithm Come In And Let's Brainstrom by Yungmakaveli01(m): 8:33pm On Aug 05, 2023
Now the first problem we'll be solving in this series is title the Tram Array

[b]Problem/b]

A city has N Tram stations numbered from 1 to N that are connected to one another and form a circle. You are given an array ticket_cost where ticket_cost[i] is the cost of a ticket between the stops number i and (i + 1) % N. The Tram can travel in both directions i.e. clockwise and anti-clockwise.

Return the minimum cost to travel between the given start and finish station.

You are given an integer N where N represents the total number of the tram stations, an integer start which represents the start station, and an integer finish which represents the finish station. You are given an array of positive integers ticket_cost where ticket_cost[i] represents the ticket cost between the station number i and (i + 1) % N. and you are to determine the minimum cost it takes to travel between the given start and finish position

Example

Assumptions

N = 4
start = 1
finish = 4
ticket_cost = [1, 2, 2, 4 ]
Approach

path1 -> 1------1-----> 2 -------2------> 3 -------2------> 4 . => 1+2+2 => 5

path2 -> 1------4------>4 . => 4

Path2 will give the minimum cost. Therefore return 4.


Question is credited to hackerearth.

see the algorithm I used in solving the given task.

https://www.youtube.com/watch?v=HzeWxbv5s7k
Re: Weekend Algorithm Come In And Let's Brainstrom by kokoBoii: 9:51am On Aug 07, 2023
grin
Re: Weekend Algorithm Come In And Let's Brainstrom by Yungmakaveli01(m): 11:12am On Aug 14, 2023
In this episode of the weekend Algo we will be taking look at a simple binary problem and see how to come up with an efficient Algo that solves the problem



https://www.youtube.com/watch?v=hPAVWSMEpBk

Pls do well to like the video and also subscribe to the channel
Re: Weekend Algorithm Come In And Let's Brainstrom by Yungmakaveli01(m): 6:32pm On Aug 20, 2023
In todays video on the weekend algorithm I showed how I came up with a particular algorithm that solved a problem from Hackerearth that has only 29% success rate so far.

The question goes like this.

Problem
You are given a permutation with length n. You want to play a game with you friend, Bob, and the rule will be as follows:

You will choose a subarray of range [l-r] from the permutation. Then, ask Bob to find the maximum element in the rest of the numbers.
You are given a permutation a contains all numbers 1 to n. And, in q queries, each query has two integers l and r.

For each query, you have to help Bob find the maximum value that does not exist in the subarray of range [l-r] from the original array.

Note: A permutation is a sequence of integers from 1 to n of length n containing each number exactly once.
For example, (1), (4, 3, 5, 1, 2), (3, 2, 1) are permutations and (1, 1), (4, 3, 1), (2, 3, 4) are not.

Input format

The first line contains two integers n and q denoting the number of elements and the number of test cases.
The second line contains n space-separated integers.
The next q lines and each line contains two integers l, r.

Output format:
Print the maximum number that does not exist in the subarray .

Sample Input:
5 3
2 3 1 5 4
1 2
2 4
2 5

Sample Output:
5
4
2

Time Limit: 2s
Memory Limit: 256
Source Limit:
Explanation
In the sample, we have a permutation (2, 3, 1, 5, 4)

the first test-case [l,r] = [1,2] so we have to find the maximum number of the array except for the subarray [1,2]

in other words, we have to find the maximum number for the subarray [3,5] which will be 5

video solution


https://www.youtube.com/watch?v=2vgDKVrcFqg&pp=ygUHaW9jb2Rlcw%3D%3D
Re: Weekend Algorithm Come In And Let's Brainstrom by Yungmakaveli01(m): 12:31pm On Oct 08, 2023
Searching is a very important concept in programming and with the
numbers of data on the internet increasing over the years the
came different types of searching algorithm.


Linear search is the very basic of all the different searching algorithm there is.
It involves checking every particular element in a given list in a sequential order i.e one after the order,
starting with the very first item until it gets to the given item that is been searched for.

In today's episode of the weekend algorithm the problem we looked at is known as
'Find Mex' and to arrive at a solution that solves the problem Linear search came into the picture.
check the video below to see how the problem was solved.


https://www.youtube.com/watch?v=CbEnG0j_hOo

Problem

You are given an integer array of length N. You have to find the mex of 'ith' item element for all 1 <= i <= N.
The of the 'ith' element is the minimum element greater than or equal to 0 which is not present in array till the 'ith' index.

Algorithm for the solution

https://www.nairaland.com/attachments/17744621_printingmex_png66ca76d3ca266de4938b4ff88ed73680

https://www.nairaland.com/attachments/17744622_findingmex_png33c4d55b02802cb4794d750d9aeff5e5
Re: Weekend Algorithm Come In And Let's Brainstrom by Yungmakaveli01(m): 12:28am On Oct 21, 2023
Linear Search is a term that is used in a situation whereby items inside a list are been searched for in a sequential manner one after another without skippin anything in between. This concept is a powerful concept that is even employed in the use of Computer Program and even in most cases our normal daily activities. Checkout the video below to see how a particular problem gotten from the hackerearth was solved using Linear Search. #Java #Algorithm #Linear_search


https://www.youtube.com/watch?v=2u1vswdigQ0
Re: Weekend Algorithm Come In And Let's Brainstrom by Yungmakaveli01(m): 9:58am On Oct 29, 2023
A new weekend, a new algorithm...

The drill remains the same, The problem, the algorithm and the solution.

In todays episode of the weekend algorithm we take a look at a problem that has to do with archers and their respective targets
and how this particular problem implemented an algorithm that made use of the very known mathematical called the Lowest common multiple also known as LCM for short, to solve the problem....

#Question Of The Day
N archers are shooting arrows at targets. There are infinite targets numbered starting with 1. The i-th archer shoots at all targets that are multiples of k-ith.

Find the smallest target that is hit by all the archers.


# Input
The first line contains an integer T - the total no. of testc ases.

T test cases follow. Each test case is of the following format:

The first line contains a natural number - N - the number of archers. The second line contains N space-separated integers, where the i-th integer denotes the value of k for the i-th archer.

# Output
For each test case, print the smallest target that is hit by all archers on a new line.

# Sample Input
1
3
2 3 4
# Sample Output
12

# Explanation

The first archer shoots at targets 2, 4, 6, 8, 10, 12, 14, ...

The second archer shoots at targets 3, 6, 9, 12, ...

The third archer shoots at targets 4, 8, 12, 16, 20, ...

The smallest target at which all archers shoot is .



https://www.youtube.com/watch?v=PNFHB8jRhkM

(1) (Reply)

Disk Drill Pro 5.5.900 & Activation Code Free / Say No To Zits And Prevent Skin Aging / It's Finally Out...awesome Content Blocker For Ios9

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 28
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.