Categorygithub.com/sandeepr0963/algorithm
module
0.0.0-20240423182229-85ece45a4c18
Repository: https://github.com/sandeepr0963/algorithm.git
Documentation: pkg.go.dev

# README

algorithm

Here the programs starting with *problem.go are based on the coding practise problems generated by https://www.dailycodingproblem.com/

Others such as palindrome.go are programs tried to practise/excel coding

1problem //Given a list of numbers and a number k, return whether any two numbers from the list add up to k. //For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.

2problem //need to take a slice and return with product of other indexes //example if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6]

4problem //find the first missing positive integer in linear time and constant space //example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3 //check what is first number and then next number isn't increment it should return increment

60problem //Given a multiset of integers, return whether it can be partitioned into two subsets whose sums are the same. //For example, given the multiset {15, 5, 20, 10, 35, 15, 10}, it would return true, since we can split it up into {15, 5, 10, 15, 10} and {20, 35}, which both add up to 55. //Given the multiset {15, 5, 20, 10, 35}, it would return false, since we can't split it up into two subsets that add up to the same sum.

61problem //Implement integer exponentiation. That is, implement the pow(x, y) function, where x and y are integers and returns x^y. //Do this faster than the naive method of repeated multiplication. //For example, pow(2, 10) should return 1024.

69problem //Given a list of integers, return the largest product that can be made by multiplying any three integers. //For example, if the list is [-10, -10, 5, 2], we should return 500, since that's -10 * -10 * 5.

70problem //A number is considered perfect if its digits sum up to exactly 10. //Given a positive integer n, return the n-th perfect number. //For example, given 1, you should return 19. Given 2, you should return 28.

101problem //Given an even number (greater than 2), return two prime numbers whose sum will be equal to the given number.

113problem /Given a string of words delimited by spaces, reverse the words in string. For example, given "hello world here", return "here world hello" //Follow-up: given a mutable string representation, can you perform this operation in-place?

138problem //Need to check if arg is greater than 25 divide by 25, less than 25 or >= 10, less than 10 or >= 5

153problem //Find an efficient algorithm to find the smallest distance (measured in number of words) between any two given words in a string. //For example, given words "hello", and "world" and a text content of "dog cat hello cat dog dog hello cat world", //return 1 because there's only one word "cat" in between the two words.

99problem //Given an unsorted array of integers, find the length of the longest consecutive elements sequence. //For example, given [100, 4, 200, 1, 3, 2], the longest consecutive element sequence is [1, 2, 3, 4]. Return its length: 4.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author