# Questions tagged [algorithm]

The tag has no usage guidance.

16 questions
Filter by
Sorted by
Tagged with
65 views

### How to merge objects in query?

I have 2 custom objects. Let's say its customObj1__c and customObj2__c. List<customObj1__c> obj1 = [SELECT Id, Name__c, Age__c FROM customObj1__c ORDER BY CreatedDate ASC]; List<customObj2__c&...
24 views

### Is there any way to perform my required logic other than with recursion applied on a tree data structure?

This is the most complex logic I've ever worked with in Salesforce. I'll try to describe my requirement in simple terms. I have a custom object which has a date field(StartDate__c), and a number ID ...
57 views

### Algorithm to calculate Risk Rewards ratio in trading?

Currently, I am developing a trading calculator where I need to calculate the ratio between Risk and Rewards (Risk:Rewards). But I am getting the ratio value in decimal (0.21) as I am directly ...
• 9
124 views

### In the 18-character ID algorithm implementation, why did they reverse the 5-character chunks?

While reading further about Salesforce Ids, I came across this article detailing how three extra characters are appended to the original 15-character record Id in order to identify the casing of each ...
1 vote
331 views

### How to convert a JSON string stored in a Content Document back to a Map and merge it with a Map of similar type? [duplicate]

I have a Map of type - Map<String, List<List<LineInfo>>> valuesMapOne = new Map<String, List<List<LineInfo>>>(); This Map is serialized and saved into a ...
328 views

### Better way of searching for values in apex list

I have a list of unique strings say 'one' to 'ten' as below: List<String> values = {'one', 'two', 'three','four','five','six','seven','eight','nine','ten'}; I have a requirement to check if the ...
• 307
48 views

### is it possible to write an algorithm in zbase32? [closed]

I have a request to generate unique codes through an algorithm. take a unique number from a sequence (maximum value 2 ^ 30) ZBase32 encoding is used to encrypt the number. The encoding alphabet is as ...
750 views

### Balanced brackets

I need to implement a function that determines whether brackets are balanced. Here are a couple of examples of how it should work: '' => true '[]' => true '{}' => true '() => true '[[]'...
• 33
2k views

### Recursive Algorthims In Apex

This is really just a general CS question. I have been trying to increase my knowledge of algorithms and data structures. And of course, every CS class is full of examples of recursive algorithms. ...
• 1,453
103 views

### Apex-optimized algorithm for "road atlas city distance matrix" style utility data? [closed]

I'd like to automate a business process that currently involves a road-atlas-style "distance chart" as seen here. When an employee is hand-reviewing records for deduplication, if a given "status" ...
• 1,217
42 views

### Creating fulsome combinations of list elements

I have been having some issues getting the logic down for the following: Simplifying, I have an N-element list of Skids defined as: public class Skid { public Integer length { get; set; } ...
39 views

### Can I do this part of code shorter and cleaner? How?

Help me please: I want to make this part of code shorter. Maybe with a few methods. But I don't know how to do that with using SOQL. To many double-parts are here. public List<Item__c> ...
• 473
1k views

### Split a List to create a separate list while satisfying 2 conditions.

I have a list (List A in image) of Cases. Each case record has a field 'External Id'. I have to create a separate List such that, for all cases which has the same F-ID's, it should take the case ...
• 820
397 views

### Sketch of heap usage prior to algorithm implementation

I'm trying to have an idea of what would be the heap usage of a certain algorithm in Salesforce, given different inputs in order to determine if I should implement it async or sync. I am aware that ...
• 3,427
997 views