Skip to content
Advertisement

Tag: algorithm

Correct Use Of Factory Pattern?

I have been doing research on the factory design pattern and was wondering if the below example, while not “textbook” is technically a correct use of it. Is there another design pattern that may fit the situation better? Answer IMO: Looks like the given code example actually implemented the Factory Method pattern with using the Method Object solution https://refactoring.guru/replace-method-with-method-object. Because

Newest version Postman creating different signature for AWS access compared to my java algorithm

So I’ve created the java algorithm for AWS signature creation, following the guidelines of AWS >https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html The algorithm is available on my github >https://github.com/marcodag/aws_signature_creation/blob/main/SignatureCreation.java These are the steps that I take: retrieve secret key, access key and token from AWS account create call on Postman (for Linux) v8.12.5, by using AWS Signature auth the call goes OK. I retrieve the

The longest Substring without Repeating Characters

I’m starting out on LeetCode, and am currently working on the problem Longest Substring Without Repeating Characters. Given a string s, find the length of the longest substring without repeating characters. Input: s = “abcabcbb” Output: 3 Explanation: The answer is “abc”, with the length of 3. I feel like my approach should work, but for some reason it fails

Find index in array based on given value

I have a sorted array of numbers with array length as n. For a given item k find index i in the sorted array where elements from index i to n are greater than the given item k. If there is no index present then return -1 This is my program: The time complexity of this approach is O(n), and

Algorithm to get the submultiples of each number in a range

I have this exercise in mind, I keep trying to solve it in Java but I’m not able to create a correct algorithm to get the submultiples of each number in a range, the start and the end of the range is user defined. Besides, the number 1 doesn’t count as a submultiple. For example, in a range between 3

Advertisement