Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,205,837 members, 7,993,910 topics. Date: Monday, 04 November 2024 at 09:33 PM |
Nairaland Forum / Science/Technology / Programming / Algorithm And Data Structure Study Section (7756 Views)
Data Structure And Algorithm With Php / Is It Possible To Learn Algorithm And Data Structures? / Nigerian Developers How Did You Master Algorithm And Problem Solving (2) (3) (4)
(1) (2) (3) (4) (5) (6) (7) (Reply) (Go Down)
Re: Algorithm And Data Structure Study Section by Nobody: 4:03am On Jan 13, 2023 |
GREATIGBOMAN: Apparently, The spam bot is refusing to allow comments with that link. //// function LongestPalindromic(input) { let joiner = ""; let joiner2 = ""; let arr = input.split("" ); let x = 0; let y = 0; let z = 0; let longestPalindrom; function checkPalindrom(str, str2) { if (str === str2 && str.length && str2.length) { if (str.length > z) { z = str.length; longestPalindrom = str; } } } while (x < arr.length) { for (item of arr) { // console.log(y) y++; if (x < 1) { joiner = joiner + item; joiner2 = item + joiner2; checkPalindrom(joiner, joiner2); } else { joiner = joiner + item; joiner2 = item + joiner2; let word = joiner.substring(x, arr.length); let word2 = joiner2.substring(0, joiner2.length - x); checkPalindrom(word, word2); } if (y === arr.length) { joiner = ""; joiner2 = ""; y = 0; } } x++; } if (x === input.length) { return longestPalindrom; } } console.log(LongestPalindromic("babad" )); 3 Likes |
Re: Algorithm And Data Structure Study Section by Nobody: 4:20am On Jan 13, 2023 |
Integer to Roman Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is written as XXVII, which is XX + V + II. Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used: I can be placed before V (5) and X (10) to make 4 and 9. X can be placed before L (50) and C (100) to make 40 and 90. C can be placed before D (500) and M (1000) to make 400 and 900. Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. Example 1: Input: 3 Output: "III" Example 2: Input: 4 Output: "IV" Example 3: Input: 9 Output: "IX" Example 4: Input: 58 Output: "LVIII" Explanation: L = 50, V = 5, III = 3. Example 5: Input: 1994 Output: "MCMXCIV" Explanation: M = 1000, CM = 900, XC = 90 and IV = 4. 1 Like |
Re: Algorithm And Data Structure Study Section by Nobody: 4:20am On Jan 13, 2023 |
GREATIGB0MAN: This should be interesting 1 Like |
Re: Algorithm And Data Structure Study Section by LikeAking: 10:23am On Jan 13, 2023 |
GREATIGB0MAN: Now u are doing ya tin, nobody is trolling you or trying to bring you down. I hope u see how sane people behave. Your solutions are uneccesrily too long, difficult to even understand what you are doing and not at it best, but people still dey cheer u on. Good luck. |
Re: Algorithm And Data Structure Study Section by Nobody: 10:36am On Jan 13, 2023 |
LikeAking: See that girl up there... Also, post your shorter solutions. You may have a hard time understanding the solution if you've not understood the problem. 2 Likes |
Re: Algorithm And Data Structure Study Section by LikeAking: 11:13am On Jan 13, 2023 |
GREATIGB0MAN: That girl no do u anything. Na u offend her with ya carless talks and trolling. Just upgrade from that your attitude, move forward. U called my APP, "ABC APP".. Down playing my effort, trying to kill my vibe. It's not ya first time.U have done worse to others. Solving this general leet code questions with answers available online, doesn't make u a good programer. I know u feel that way. Expected beta solutions from u, judging by ya bragado. It's obvious u are just pasting leet code solutions here.. But I go still cheer u on... Try upgrade... Learn from ya mistakes. 2 Likes |
Re: Algorithm And Data Structure Study Section by Nobody: 11:18am On Jan 13, 2023 |
LikeAking: All this Una talk... noby only answers available online. I take my time to solve this problems on my own without peeping or using already made solutions... That is why you'd notice most times my solution even if they work/pass test cases may not be the best. If I was to search online, of course I'd post the best solutions. Believe me or not, agree or disagree, that one na your headache... if I the do I post my solution here... na my own knowledge I the increase not yours 5 Likes |
Re: Algorithm And Data Structure Study Section by Nobody: 11:20am On Jan 13, 2023 |
LikeAking: Also, I never trolled on anyone that didn't deserve it... your app was basic... no hard feelings there. 2 Likes |
Re: Algorithm And Data Structure Study Section by LikeAking: 11:28am On Jan 13, 2023 |
GREATIGB0MAN: Funny guy. The solutions are all online any body can solve them, by peeping at the solutions. It's not your first time seeing this leet code questions, don't lie. Don't claim u didn't peep.. Na basic DSA be this oh.. Why not take this free time of yours to replicate my ABC APP to spite me. U braged about doing that. Remember u made a promise u will do that. |
Re: Algorithm And Data Structure Study Section by Nobody: 11:37am On Jan 13, 2023 |
LikeAking: It's normal for people to hate what they don't understand. U way the beg that other guy to explain question for you. Also. Medium questions on leetcode are not basic questions. U told me I can't contribute or join a thread like this. Now I'm contributing and posting but u haven't solved a single question or posted anything meaningful. Just like every reasonable person should, I do break down this problems on a piece of paper before trying them out. 4 Likes |
Re: Algorithm And Data Structure Study Section by Nobody: 11:37am On Jan 13, 2023 |
LikeAking: See person 3 Likes |
Re: Algorithm And Data Structure Study Section by Nobody: 11:38am On Jan 13, 2023 |
LikeAking: Have u finally understood this question. Your solution is needed 3 Likes |
Re: Algorithm And Data Structure Study Section by LikeAking: 11:47am On Jan 13, 2023 |
GREATIGB0MAN: When u replicate my ABC APP come make we talk.. As for that question I asked that guy, it was just a hand of friendship. |
Re: Algorithm And Data Structure Study Section by Nobody: 11:50am On Jan 13, 2023 |
LikeAking: Ok Sir... way the app self 3 Likes |
Re: Algorithm And Data Structure Study Section by LikeAking: 11:58am On Jan 13, 2023 |
GREATIGB0MAN: Make Yanga APP. Link : https://www.nairaland.com/7488114/little-gift-ui-guys-non. I built roughly in less than 48 hours. I believe u have your on tricks at your disposal. Good luck. Use this as a guide
|
Re: Algorithm And Data Structure Study Section by sqlPAIN: 12:01pm On Jan 13, 2023 |
Bunch of wemen 1 Like |
Re: Algorithm And Data Structure Study Section by Maxxim: 9:30pm On Jan 13, 2023 |
sqlPAIN:. |
Re: Algorithm And Data Structure Study Section by namikaze: 9:36pm On Jan 13, 2023 |
GREATIGBOMAN: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 , for a max length of 1000, I think I can make it pass with c++ with the bruteforce approach what's the time complexity of your solution? 1 Like |
Re: Algorithm And Data Structure Study Section by Nobody: 3:59am On Jan 14, 2023 |
namikaze: Na now that anti spam bot the unban me... I didn't bruteforce. I didn't compare all combinations of the words to get a palindrome. I just sliced the words by there first and last index then compare to see if there's a palindrome. If there's a palindrome I check the length and set it to a variable say (Z) then set the string of that palindrome to (newStringVal) If there's another palindrome I check the length then compare it to the previous variable length. If the length of this new palindrome is greater than the previous I set the palindromic string to (newStringVal) overwriting the previous. 1 Like
|
Re: Algorithm And Data Structure Study Section by Nobody: 4:01am On Jan 14, 2023 |
LikeAking: Lol... It's not necessary but I'll s build your app bro. U don rush say na 48 hours |
Re: Algorithm And Data Structure Study Section by Nobody: 7:20am On Jan 14, 2023 |
LikeAking: I'm done building your app bro. Also used tailwindCss instead before u go say I peep your code. To save the image as Png I used htmlToImage and not the one you used, but your version wasn't that responsive and the shuffling was buggy. Will share link with you when i wake up. 1 Like
|
Re: Algorithm And Data Structure Study Section by qtguru(m): 1:04pm On Jan 14, 2023 |
GREATIGBOMAN: Respect. you didn't need to take the challenge but regardless you did and not bad at all. 3 Likes |
Re: Algorithm And Data Structure Study Section by qtguru(m): 1:04pm On Jan 14, 2023 |
I'll join starting tomorrow , it will be fun |
Re: Algorithm And Data Structure Study Section by Nobody: 6:58pm On Jan 14, 2023 |
LikeAking: was done with it in the morning, it's now I'm hosting it. Check out your app I remade here. Note: I didn't put much attention to the CSS even. You may notice some errors in iPhones mostly from the download/reset button . will fix it anytime less busy. Just wanted it to work... https://www [.] bona 9ja[.]online/yanga/ remove [ ] 4 Likes 1 Share
|
Re: Algorithm And Data Structure Study Section by LikeAking: 11:53pm On Jan 14, 2023 |
GREATIGBOMAN: Let me be fair, u tried... This your version can't spite mine, e no reach. So u failed... U didn't keep to your promise of spiting me with ur version. Some functions are not working properly, like d images reorder button... 1 Like |
Re: Algorithm And Data Structure Study Section by LikeAking: 11:55pm On Jan 14, 2023 |
GREATIGBOMAN: Less than 48 hours.. |
Re: Algorithm And Data Structure Study Section by Nobody: 4:21am On Jan 15, 2023 |
LikeAking: lol, ok... Na u sabi... but know it's less than 8 hrs work. Besides... You can't be the judge. |
Re: Algorithm And Data Structure Study Section by LikeAking: 2:13pm On Jan 15, 2023 |
GREATIGBOMAN: 8 hrs peeping n cloning my APP? EVERY TIN DON ALREADY SET FOR YOU.. 2 Likes 1 Share |
Re: Algorithm And Data Structure Study Section by Nobody: 2:50pm On Jan 15, 2023 |
LikeAking: Nawaooo Humans self. Now na peeping and cloning. Your initial thought was I could not build it lol. Now I built it with way shorter time than you did now you're capping... 8 hours self was not like i sat down one place... also went out to watch a football match and other things. let me guess, I also peep your javascript functions. Our apps are totally different by the way... Not just by Looks. Your app: Users must Upload 6 images at once/They can't even change an image they don't like. Mine, You can upload one by one and also change the ones you don't like. Your app has no interactive transitions, like on hover and stuff like that. Your shuffling isn't that cool... My shuffling works by randomizing the selected images with animation added to them for a better UX experience. Also. I used Tailwind(For CSS) to let you know I did everything from the ground up. I presume you used NextJs while I, on the other hand, used ReactJs. Also totally different packages from what you used. in a Nutshell, I don't expect you to be impressed by my version. The point is. I just wanted you to know the App wasn't that difficult to build period. If you get another one U fit show me You are still my guy nevertheless... Sorry for my actions/words towards & against you before, it was not necessary 5 Likes |
Re: Algorithm And Data Structure Study Section by Nobody: 8:26pm On Feb 12, 2023 |
Hi guys, I have a question on javascript. I am learning how javascript handles asynchronous programming and I learnt that javascript is singlethreaded and uses callback queue and micro task queue to schedule and it's the job of event loop to put it back after the call stack is empty. My question now is that isn't that the same thing as deffering function to the end of the script? let's say I have a function that's blocking (It takes time to run).. GeneratePrime(). Can't I just manually put it at the end of the script so that it will allow others to run without going through the hassle of making it asynchronous, since the whole purpose of making it asynchronous is to defer it to the end of the script? And what I mean by making it asynchronous is that I pass it into setTimeout so that it can go into callback queue or make a promise so it can go into microtask queue. Or is there something I am missing? I know it might sound silly, I am a beginner and my system is faulty so I can't test the concept. Qtguru and others. Thanks in advance, sirs/mas. |
Re: Algorithm And Data Structure Study Section by Deicide: 11:39am On Feb 14, 2023 |
Phamo0:Yes you can call it last. |
(1) (2) (3) (4) (5) (6) (7) (Reply)
How To Generate A Word File .doc/.docx Using Php / Web Development Using ASP / I Want To Build Websites All By Myself
(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. 87 |