Software Development and Programming Careers (Official Discussion Thread)

Kwabena

I am STEM.
Joined
Nov 25, 2016
Messages
11,741
Reputation
1,014
Daps
31,490
Reppin
Antibes
it was their simple twosum bullshyt. Was trying to come up with some samurai-type ninja solution with O(n) or better complexity

Code:
std::vector<int> twoSum( std::vector<int>& nums, int target ) {

    std::vector<int> indices;
    std::map<int, int> diff_map;
    std::size_t idx = 0;

    std::for_each(nums.begin(), nums.end(), [&](int value) {
        diff_map.insert({target-value, idx++});
        }); 

    for (unsigned int n = 0; n < nums.size(); n++) {
        if (diff_map.find(nums[n]) != diff_map.end()) {
            if (n != diff_map[nums[n]]) {
                indices.push_back(n);
                indices.push_back(diff_map[nums[n]]);
                return indices;
            }
        }
    }

    return { 0 };
}
C++ :yes:

I give myself like 30-45 minutes before I give up and look at solutions
 

Sonny Bonds

Superstar
Supporter
Joined
Apr 24, 2014
Messages
4,622
Reputation
916
Daps
13,259
So I have this:
It gives me the issue data, but not the comments
Code:
import requests
import json
import base64

cred =  "Basic " + base64.b64encode(b'username@company.com:apikeygoeshere').decode("utf-8")

headers = {
   "Accept": "application/json",
   "Content-Type": "application/json",
   "Authorization": cred
}

projecKey = IT

# Update your site url
url = "https://company.atlassian.net/rest/api/3/search?jql=project=" + projectKey

response = requests.request(
   "GET",
   url,
   headers=headers
)

json_data = json.loads(response.text)

size = 100
count = 0
start= count * size

# Display issues
for item in json_data["issues"]:
    print(item["id"] + "\t" + item["key"] + "\t" +
        item["fields"]["issuetype"]["name"] + "\t" +
        item["fields"]["created"]+ "\t" +
        item["fields"]["creator"]["displayName"] + "\t" +
        item["fields"]["status"]["name"] + "\t" +
        item["fields"]["summary"]
    )
But when I try to implement this to get the comments, I clearly don't know what I'm doing.

- I tried changing the url variable to get a response from /rest/api/3/issue/{issueIdOrKey}/comment, but it didn't work
 

Sonny Bonds

Superstar
Supporter
Joined
Apr 24, 2014
Messages
4,622
Reputation
916
Daps
13,259
I don't understand how to reference the response data I get from an API.
 

Rev Leon Lonnie Love

damned mine eyes, DAMNED mine eyes!!
Joined
Nov 11, 2017
Messages
21,912
Reputation
5,478
Daps
88,996
What's a good book for c and c++
Just take a course, it will be faster to learn.

If you already have skill and experience in another language then just read the documentation to get familiar with syntax and language constructs....then start using it to build whatever u want while googling for help when stuck. Thats the quickest way if u already can code in another language
 
Top