• Breaking News

    Friday, March 26, 2021

    Competitive Programming Problem Computer Science

    Competitive Programming Problem Computer Science


    Competitive Programming Problem

    Posted: 26 Mar 2021 02:49 AM PDT

    Hi there everyone,

    I'm a first-year CS student, and I recently started doing some **basic** competitive programming problems, mainly ones from contests in my country which are meant for 15-18 years olds, they're not for classes or anything, they're just for me to have fun, and a teacher gives a way to test them, but this isn't part of uni or anything.

    The thing is since it's my first experience with competitive programming, they're obviously quite hard.

    I've managed to solve most of them, only failing the previous one, which was in fact the hardest of all the problems set according to my teacher. ( if you guys want I can post it here too, it's actually a really fun one :) )

    Now I'm stuck in a new exercise, and I wanted to get some help.

    Problem

    Give a string s ( always lower case, no spaces or symbols ), and an integer n, return the biggest subsequence of the string, which only uses n letters.

    Example Input:
    abbbbcccddd
    3

    Output:

    bbbbcccddd

    If two+ sequences are found, return the first one.

    String length is at most 10^6 and n is [obviously :P ] at most 26.

    What I have so far?

    All I have so far is that it can be done in O(n), and I'm guessing I have to use a secondary array, but this is the first problem of this type I've done and I've spent a long time with it and never got that far.

    I've managed to get it a bit better, using binary search, but it would still be n^2 at least, only having minor improvements in specific cases, so I don't think that's the way.

    Sorry if this isn't the right place to post this, but I really didn't find any subs to post this, apart from other CS subs.

    submitted by /u/GooglyEyedGramma
    [link] [comments]

    Quantum brain: The hidden answers to the open questions in AI

    Posted: 25 Mar 2021 09:14 PM PDT

    Hi, I wanna login but I always get the failed login. I know there is something wrong in the getline part but I have no idea how to fixed it . (I'm using c++ and I can't use other predefined library) Thanks a lot if you can help me !

    Posted: 25 Mar 2021 11:04 PM PDT

    I've include my whole code and the part I'm struggling with is the void login() part.

    #include<iostream> #include<iomanip> #include <fstream> #include <string> using namespace std; void login(); void reg(); int main() { welcome(); int choice; cout << "1. login " << endl; cout << "2. register" << endl; cout << "3.Exit" << endl; cout << "\n Please key in which one you want to do :"; cin >> choice; cout << endl; switch (choice) { case 1: login(); break; case 2: reg(); break; case 3: system("cls"); cout << "Thanks for using this program\n"; break; default: system("cls"); cout << "Please enter the number from 1-3 only !\n" << endl; } system("pause"); } void login() { system("cls"); string username, password, un, pwd; cout << "please enter the following details" << endl; cout << "UserName :"; cin >> username; cout << "Password :"; cin >> password; ifstream Userin("name&pwd.txt");// I'm not sure about this part getline(Userin, un); getline(Userin, pwd); if (un == username && pwd == password) { cout << "\nWelcome " << username << "\nThanks for logging in\n"; cin.get(); cin.get(); system("pause"); main(); } else { cout << "\nFailed to login\nPlease check your username and password\n";//I always get this even though my username and password is corect system("pause"); main(); } Userin.close(); } void reg() { string newuser, newpass, newpass2, email, nu, npwd; system("cls"); cout << "Enter username :"; cin >> newuser; cout << "Enter password :"; cin >> newpass; cout << "Please confirm your password :"; cin >> newpass2; if (newpass != newpass2) { cout << "your password is incorrect!\n"; } else { cout << "Enter your email: "; cin >> email; } ofstream Userreg("name&pwd.txt", ios::app); Userreg << newuser << ' ' << newpass << email << endl; system("cls"); cout << "\nRegistration Sucessful\n"; main(); 
    submitted by /u/BrightKnight0110
    [link] [comments]

    What are some examples of real world problems solved by parallel computing? And of distributed computing?

    Posted: 25 Mar 2021 03:18 PM PDT

    I think I understand the differences between these two concepts but I would like to dive deeper into one of these fields. Before I do, I'm wondering what real world problems these solve. I am interested in AI/ML and I know GPUs are central in DL so parallel computing comes into play here. I also know that supercomputers utilize massive distributed systems.

    So I am looking for more examples of real world applications that distinguish these. I don't have much experience working with low level systems which I think is vital for parallel computing, and I don't have much experience with networking which I think is vital for distributed computing.

    Beyond this, I was wondering which field would be considered "deeper", e.g. more to learn.

    submitted by /u/insanelylogical
    [link] [comments]

    [N] Tsinghua & MIT’s P-Tuning Boosts Performance on NLU Benchmarks

    Posted: 25 Mar 2021 05:57 PM PDT

    Tsinghua & MIT researchers break the stereotype that GPTs can generate but not understand language, showing that GPTs can compete with BERT models on natural language understanding tasks using a novel P-tuning method that can also improve BERT performance in both few-shot and supervised settings.

    Here is a quick read: GPT Understands, Too! Tsinghua & MIT's P-Tuning Boosts Performance on NLU Benchmarks

    The paper GPT Understands, Too is on arXiv.

    submitted by /u/Yuqing7
    [link] [comments]

    VisuAlgo in Python

    Posted: 25 Mar 2021 05:12 PM PDT

    Hello everyone, I want to know if there's a library or something where I can start learning to make a program similar to VisuAlgo where you can create graphs graphically and use different algorithms, I want to code it using Python.

    I'll leave an image as example.

    You can hold and create an edge from a vertex or clic and create a vertex

    submitted by /u/fexx3l
    [link] [comments]

    What are the differences between these two types of quicksorts that I keep seeing?

    Posted: 25 Mar 2021 11:05 AM PDT

    I'm learning about quicksort right now so I've been watching tons of explanations by different people. Something I find somewhat frustrating is how there seems to be two different ways of working through the array.

    Lets assume the pivot is swapped to be the last item in the list. One technique then puts a pointer i to be on the left side of the list, and a second pointer j on the right side of the list (just left of the pivot. Then i goes through until it lands on an item that is greater than or equal to the pivot. Then j goes through the list to the left until it finds an item less than the pivot. Once this happens, the items at i and j swap (or if i and j have crossed, the pivot is swapped with i). This is one technique, and it's one I'm comfortable with.

    There also seems to be a second technique, which I don't fully understand because I haven't practiced it like I have the other one. It has both of the pointers i and j on the left side. I could be wrong, but I believe i starts at -1 and j starts at 0? Then j starts incrementing until it's found a number that is less than the pivot, then i is incremented, and the values at i and j are swapped. I might be misunderstanding this technique, but this method seems hella inefficient (lots of swaps).

    Why are there two techniques? Does it matter which one is used?

    submitted by /u/Missing_Back
    [link] [comments]

    This subreddit is ridiculously overmodded.

    Posted: 25 Mar 2021 03:26 PM PDT

    It's often painstaking to come up with a post that doesn't get auto-removed. I am afraid to right any more details for fear this will get auto-removed too.

    edit: I added an example in a comment reply

    edit 2: There are over a million members in the subreddit yet this subreddit averages only a couple posts a day. To me, that is highly indicative of overmodding. I am sure many posts get removed and people become discouraged from posting here.

    submitted by /u/insanelylogical
    [link] [comments]

    No comments:

    Post a Comment