Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,205,598 members, 7,993,046 topics. Date: Monday, 04 November 2024 at 02:29 AM

Namikaze's Posts

Nairaland Forum / Namikaze's Profile / Namikaze's Posts

(1) (2) (3) (4) (5) (6) (7) (of 7 pages)

Fashion / Re: What Can I Apply On My Hair To Make It Grow Faster? (Pics) by namikaze: 4:08pm On Sep 23, 2023
Kuramushe:
Marijuana dust, mix it with original petroleum jelly( Vaseline). Deeply rub it on your head regularly.quote author=Chenult post=117709632]Early this year, I cut my Afro and since then I have been on lowcut, so I've decided to grow it back but my hair grows slowly. I've been applying raw Aloe Vera gel on it for the past 1 month but it seem not to be working and I recently stopped applying it.

As a matter of fact, I need something that I can apply on it and it would grow like a tree planted by the riverside from now to December. I don't mind taking some non harmful drugs if need be - I learnt some biotin drug can do the magic, but I don't know how true it is.

I don't want to be on lowcut this festive period, I want to carry dreadlocks. There's one dope dreadlock style (similar to olamide's current hairstyle) that is in vogue now - that's how I want my hair to be by Xmas.


Pls I need useful suggestions.
By dust you mean dried marijuana flower/leaves?
Fashion / Re: What Can I Apply On My Hair To Make It Grow Faster? (Pics) by namikaze: 4:02pm On Sep 23, 2023
637oluwadetan:
Nairalanders no dey fail to deliver. Find marijuana mix with so fine. Pay me later. Omo, na anything dey reach FP nowadays.SMH. Nairalanders no dey fail to deliver. Find marijuana mix with so fine. Pay me later. Omo, na anything dey reach FP nowadays.SMH. ...
the seed or the leave/flower people smoke?
Technology Market / Re: Zealot S55/S51 Portable Bluetooth Speaker Needed In Minna by namikaze: 6:04am On Sep 09, 2023
Mozino007:
I have s67 clean used
how much then?
Technology Market / Re: Zealot S55/S51 Portable Bluetooth Speaker Needed In Minna by namikaze: 5:44am On Sep 09, 2023
Mozino007:
used or new
new but might consider clean used.
Technology Market / Re: Zealot S55/S51 Portable Bluetooth Speaker Needed In Minna by namikaze: 5:38am On Sep 09, 2023
Mozino007:
How many pieces?
Just one, I'm the consumer.
Technology Market / Zealot S55/S51 Portable Bluetooth Speaker Needed In Minna by namikaze: 5:08am On Sep 09, 2023
Zealot S55 or S51 Portable Bluetooth Speaker needed in Minna!
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 10:14am On Mar 16, 2023
richebony:



Thanks a lot man !!


function commonElements(first, second) {
const res = [];
const map = {};

for (let element of first) {
map[element] = (map[element] || 0) + 1;
}

for (element of second) {
if (map[element]) {
res.push(element);
map[element]--;
}
}
return res
}


Hope u don't mind my asking, but how many languages do you actually know because I have seen your code in golang, I once confused you with another handle ( decide )
I mostly use golang for my side projects, js(nodejs) because I gotta get a job cry, python for DSA wink. I also know Java, C and C++ but I don't use them anymore.

2 Likes

Programming / Re: Algorithm And Data Structure Study Section by namikaze: 8:21pm On Mar 15, 2023
richebony:
Please can anyone come up with an optimized solution for solving this PS?

Design an algorithm to find all the common elements in two sorted lists of
numbers. For example, for the lists 2, 5, 5, 5 and 2, 2, 3, 5, 5, 7, the output
should be 2, 5, 5.

Time complexity should be 0(n) or better
NB : am terrible with algos so any contribution would be highly appreciated

namikaze
truthcoder
qtguru
tensazangetsu20
Have you tried using an Hashmap/Set?

For example:

from collections import Counter

def common_elements(A, B):
res, map = [], Counter(A)
for num in B:
if map[num]:
res.append(num)
map[num] -= 1
return res


def test():
listA = [2, 5, 5, 5]
listB = [2, 2, 3, 5, 5, 7]
got = common_elements(listA, listB)
want = [2, 5, 5]
assert got == want, f'got {got} want {want}'

test()

1 Like

Programming / Re: Discussion: What Is Your Opinion Of Mongodb by namikaze: 9:37pm On Jan 13, 2023
truthCoder:

Give cockroach db a trial. Spool up a cluster and you would love it.
It uses gcp or aws and gives you a choice.
Yeah sure, thanks for the heads up.
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 9:36pm On Jan 13, 2023
GREATIGBOMAN:


Finally got leetcode to accept the answer after 3-4 refactoring. grin
interesting problem,
My approach is to use dynamic programming, i.e reuse the result of a previous palindrome check, this should boil down the runtime of the palindrome checker to ~ O(1).
To cover all substrings we need two loops, making it O(n²), the final runtime becomes O(n²) instead of O(³) of the bruteforce approach.
I'm having a hard time coming up the O(1) palindrome check tho grin, for a max length of 1000, I think I can make it pass with c++ with the bruteforce approach grin
what's the time complexity of your solution?

1 Like

Programming / Re: Discussion: What Is Your Opinion Of Mongodb by namikaze: 5:47pm On Jan 13, 2023
truthCoder:


Same as firestore.

Non relational databases have their own peculiarities and should only be deployed to projects that benefit immensely from such structures. I don’t quite get why i would deploy a mongo db instance only to now hack at it with mongoose.

I think firestore is the cheapest of their bunch but I might be wrong. I am more skewed towards psql.

I want to be able to ‘see’ the data in my head as i write the codes.
I agree, I mostly use postgres for my projects
sometimes though a nosql db might be better choice, say for logs, metrics or 1 dimensional entity, and for these, I think I'll ditch mongo for the newer nosql dbs provided by aws,gcp etc.

1 Like

Programming / Re: Discussion: What Is Your Opinion Of Mongodb by namikaze: 9:40am On Jan 13, 2023
truthCoder:


Relational databases are time tested and are actually the more practical option in many instances. Imagine the headache involved in deploying a banking app with mongodb.

I choose distributed relational databases for most of my deploys now due to their resilience. They are set up and forget systems with automated back ups and guaranteed resilience.

Mongodb is still a great choice for projects with many sub data types like articles and comments. Mongodb would work well with a site like Nairaland for example if Seun plans on upgrading the comments to allow upvotes and downvotes, like in Reddit.
valid argument, but what about something like documentdb provided by both aws and azure, they do the same thing as mongodb but are generally faster, cheaper and easier to setup?
Programming / Re: Discussion: What Is Your Opinion Of Mongodb by namikaze: 9:36am On Jan 13, 2023
post=119977775:
Depends on what you want to do?.

For example mongo has more data support for a Nosql database where as dynamo doesn't.. even uploads are limited
yeah it mostly depends,
aws for example provides documentdb with a very similar api to mongodb but is faster and much more cheaper.
Programming / Re: Discussion: What Is Your Opinion Of Mongodb by namikaze: 9:33am On Jan 13, 2023
GREATIGBOMAN:
This cockroachDB always cracks me up.

Wonder who came up with that name. grin kiss
lol, like why cockroach, whats the meaning behind cockroach, and to think there are probably some paid "professionals" who came up with the name grin grin
Programming / Discussion: What Is Your Opinion Of Mongodb by namikaze: 8:14pm On Jan 12, 2023
What do you think?
The mongodb hype seems to have died down overall. These days there seems to be more better (arguably), cheaper, easier alternatives coming up, usually offered by cloud providers.
would you rather use mongodb for a new project or any of the newer dynamodb, cockroach db, cosmos e.t.c databases ?
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 8:05pm On Jan 12, 2023
GREATIGBOMAN:


Javascript solution

https://jdoodle.com/ia/C7U

nested loops... before you come for my head... they are different methods to solve this question, one of such is using a recursive function.

simply use the one you're most comfortable with.
nicee
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 7:54pm On Jan 11, 2023
Sleekcode:
Letter Combinations of a Phone Number
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.

A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.




Example:

Input: "23"
Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
Note:

Although the above answer is in lexicographical order, your answer could be in any order you want.

Difficulty= Medium
with recursive dfs
jdoodle.com/ia/C7K

map = {
'2':"abc",'3':"def",'4':"ghi",
'5':"jkl", '6':"mno",'7':"pqrs",
'8':"tuv",'9':"wxyz"
}

def letterCombinations(s, cur="", res=[]):
if s == "":
res.append(cur)
return

n, s = s[0], s[1:]
for adj in map[n]:
letterCombinations(s, cur+adj, res)

return res


s = "23"
print(letterCombinations(s))
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 8:31am On Jan 10, 2023
GREATIGBOMAN:
namikaze can u be posting like 1 question per day?
sure

1 Like 1 Share

Programming / Re: Algorithm And Data Structure Study Section by namikaze: 12:58pm On Jan 08, 2023
GREATIGBOMAN:

Javascript.
function medianStreams() { var input = [2, 1, 4, 7, 2, 0, 5]; var joiner = []; var output = []; for (let num of input) { joiner.push(num); if (joiner.length === 1) { output.push(joiner[0]); } else { if (joiner.length % 2 === 0) { let evenMiddle = joiner.sort().length / 2; let average = joiner[evenMiddle] + joiner[evenMiddle - 1]; output.push(average/2); } else { let oddMiddle = joiner.sort().length - 1; output.push(joiner[oddMiddle / 2]); } } } console.log(output); return output; } medianStreams();
https://www.jdoodle.com/ia/BWD
fails some test cases, for example, arr = [2,6,10,1,0]; correct answer should be [2,4,6,4,2], yours:

Programming / Re: Algorithm And Data Structure Study Section by namikaze: 7:23pm On Jan 07, 2023
engrAAS:


import sys
import math

class Node:
def __init__(self, value, color, left=None, right=None, parent=None):
self.value = value
self.color = color
self.left = left
self.right = right
self.parent = parent

class RedBlackTree:
def __init__(self):
self.root = None

def insert(self, value):
new_node = Node(value, "RED"wink
self.insert_node(new_node)

def insert_node(self, new_node):
if self.root is None:
# the tree is empty, the new node is the root
self.root = new_node
else:
current_node = self.root
while True:
if new_node.value < current_node.value:
# the new node goes in the left subtree
if current_node.left is None:
# the current node has no left child, the new node becomes its left child
current_node.left = new_node
new_node.parent = current_node
self.rebalance(new_node)
break
else:
# the current node has a left child, we continue the search in the left subtree
current_node = current_node.left
else:
# the new node goes in the right subtree
if current_node.right is None:
# the current node has no right child, the new node becomes its right child
current_node.right = new_node
new_node.parent = current_node
self.rebalance(new_node)
break
else:
# the current node has a right child, we continue the search in the right subtree
current_node = current_node.right

def find_node(self, value):
current_node = self.root
while current_node is not None:
if value == current_node.value:
# we found the node, return it
return current_node
elif value < current_node.value:
# the value we are looking for is in the left subtree
current_node = current_node.left
else:
# the value we are looking for is in the right subtree
current_node = current_node.right
# we didn't find the node, return None
return None

def count(self, node):
if node is None:
return 0
else:
return 1 + self.count(node.left) + self.count(node.right)

def find_median(self):
# get the total number of nodes in the tree
total_count = self.count(self.root)
HENCE I USED chatGPT
wrong answer, solved a completely different problem (it implemented a red black tree, which I'm guessing is still buggy).
I've tried chatGPT before, it always gives wrong solutions except for the most basic and generic problems, you'd be better of solving a problem from scratch than debugging it's solutions.
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 10:00am On Jan 06, 2023
GREATIGBOMAN:

You never mentioned this should be a sorted array
no it's not sorted
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 9:58am On Jan 06, 2023
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 2:42pm On Jan 05, 2023
MadarasBlade:


Please don't waste your time reading this book, unless you know how to read and write maths proofs. It isn't for everyone.
Agree, it's too theoretical
Programming / Re: I Want To Work At Google: Journey Of A Software Developer by namikaze: 7:08pm On Dec 31, 2022
AlchemyOfCodes:
Nithub
I see, first time hearing of it tho.
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 3:50pm On Dec 28, 2022
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 3:41pm On Dec 28, 2022
truthCoder2:

looks good,
Ideally you should use some kind of online editor so it's easier to test against different test cases.
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 2:49pm On Dec 28, 2022
found this interesting problem;

Given a sorted list of numbers, return a list of strings that
represent all of the consecutive numbers.
Example:
Input: [0, 1, 2, 5, 7, 8, 9, 9, 10, 11, 15]
Output: ['0->2', '5->5', '7->11', '15->15']
Assume that all numbers will be greater than or equal to 0, and
each element can repeat.

let's see what you guys come up with
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 2:39pm On Dec 28, 2022
truthCoder2:

10 seconds?
Many servers would have timed out by then.
yeah but that was before production. That was from my hng internship.
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 12:25pm On Dec 28, 2022
qtguru:


In my experience it's when performance is key, a function that takes 5 secs to go through all items in array might prob take more time, when going through 1 million items, so Algo and DS comes in that context, so u can know your order of growth and best algo to run at optimal time.



True, one time I had to optimised a poorly implemented delete endpoint, the bottleneck was simply the way the previous dev handled the array and database calls, average response time lowered from 10s to 1s.

1 Like

Programming / Re: Algorithm And Data Structure Study Section by namikaze: 9:26pm On Dec 26, 2022
I don't think so, what you listed are basic data types, data structures on the other hand are a composition of these types and it's accompanying structure/rule, such as a node, a composition of an int | string | float e.t.c and a pointer.
Abstract data structures are abstract, which means the underlying implementation can differ, a stack, an ADT, can have both array and linkedlists or even queue implementations, an array however is concrete and structurally fixed.
That said, apart from array and linked lists, which both implement the list ADT, most other data structures are actually ADTs.
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 7:26pm On Dec 25, 2022
my solution, Go: https://replit.com:/@usmansadik96/Go?s=app
Programming / Re: Algorithm And Data Structure Study Section by namikaze: 5:42pm On Dec 25, 2022
let's all try this:

You are given a stream of numbers. Compute the median for
each new element .
Eg. Given [2, 1, 4, 7, 2, 0, 5], the algorithm should output [2, 1.5,
2, 3.0, 2, 2, 2]
Here's a starting point:

def running_median(stream):
# Fill this in.
running_median([2, 1, 4, 7, 2, 0, 5])
# 2 1.5 2 3.0 2 2.0 2


remember, your solution could be in any language and should be from an online code editor like replit/onecompiler.

(1) (2) (3) (4) (5) (6) (7) (of 7 pages)

(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. 48
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.