All Questions
13,675
questions
0
votes
0
answers
9
views
Facing issues with a DP algorithm implementation (not able to clear majority of test cases)
A user maintains a list of negative and positive ratings for movies in a collection. The user wants to choose some subsequence of movies from the collection to bring such that the following conditions ...
0
votes
0
answers
19
views
The model(DecisionTreeClassifier) gives wrong results
I'm taking a machine learning course with an assignment to implement a fit method for DecisionTreeClassifier. Here are the links for more information:
https://stepik.org/lesson/333977/step/8?auth=...
-7
votes
1
answer
51
views
WiggleSort: giving wrong output? [closed]
I am trying to solve LeetCode problem 324. Wiggle Sort II:
Given an integer array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....
You may assume the input array always ...
-1
votes
0
answers
42
views
What is the time complexity of list1==list2 operation in Python? [duplicate]
It was my understanding that a condition equating operation would always be O(1) as we are simply checking if LHS is same as RHS.
But this scenario got me thinking.
if list1 == list2:
print("Hi&...
0
votes
1
answer
53
views
Understanding Time complexity of nested sorting
I am solving this LeetCode problem 1636. Sort Array by Increasing Frequency:
Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple ...
3
votes
2
answers
105
views
A more efficient algorithm in finding the number of distinct decompositions a number has using only repdigits
This is a problem from a previous semester that I am trying to upsolve. I am trying to solve a problem involving the total number of ways of decomposing a number using only repdigits. A repdigit is a ...
0
votes
0
answers
19
views
Modified accel asc algorithm
I wanted to make an accel asc algorithm that only outputs partitions that only have terms that are smaller than or equal to n. For example: if I want the partitions of 4, and n = 2, the wanted ...
1
vote
1
answer
66
views
Why is this algorithm O(n*n) - Manacher algorithm implementation?
So I was recently doing leetcode problem number 5 - longest palindromic substring, which outputs the longest palindromic substring out of a string. I have studied Manacher's algorithm but I didn't ...
1
vote
1
answer
179
views
Permutation summation in Pandas dataframe growing super exponentially
I have a pandas dataframe that looks like
import pandas as pd
data = {
"Race_ID": [2,2,2,2,2,5,5,5,5,5,5],
"Student_ID": [1,2,3,4,5,9,10,2,3,6,5],
"theta": [8,9,2,...
-8
votes
1
answer
62
views
I have a task to count the number of times I've played music from favorite artists and I need to rank it from most played to least played [closed]
What is the difference between the first function and the second function if they do the same task and what is faster?
Note that the first function of GPT4 chat
def selectionSort(arr):
""...
5
votes
3
answers
218
views
Multiplication of huge massive of numbers in python
I'm working on a small python program for myself and I need an algorithm for fast multiplication of a huge array with numbers (over 660 000 numbers, each is 9 digits). The result number is over 4 ...
0
votes
2
answers
60
views
Why is the last digit incorrect in my timing attack password cracker using Python?
I'm working on a timing attack to crack a password using Python. My goal is to measure the time it takes to check each digit of the password and use this information to deduce the correct digits. The ...
2
votes
3
answers
84
views
Find number of redundant edges in components of a graph
I'm trying to solve problem 1319 on Leetcode, which is as follows:
There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai,...
3
votes
2
answers
91
views
What is wrong in my solution for Leetcode's RansomNote
I am working on the Leetcode problem 383. Ransom Note:
Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.
...
0
votes
1
answer
53
views
How to Rewrite a Polynomial as a Sum of Two Squares Using Python? [closed]
I need help rewriting the following algebraic expression using Python
Given the input expression:
x**2 - 2*x*y + 2*y**2 + 2*x - 10*y + 17
The output should be the sum of two squares:
(x - y + 1)**2 + ...