As a newbie programmer
As a newbie programmer

As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Dcoder Admiration @ Dcoder

Problem: Dcoder has N members each numbered from 1 to N. A member admires other member if its number divides the other member's number.    Given a number N you need to find the number of people with odd number of admirers   Input: T the number of tes...

Lochard 1 minute read 6 Aug 2023 0 comments $0.01

Leetcode - 139. Word Break

Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.   Note that the same word in the dictionary may be reused multiple times in the segmentation.  ...

Lochard 1 minute read 5 Aug 2023 0 comments $0.02

Word Frequency @Dcoder

Title: Word Frequency Problem: You will be given a group of words. You need to print all unique words in that group in descending order of their frequency, i.e the word repeated most number of times will come first. In case of two words having the sa...

Lochard 1 minute read 4 Aug 2023 0 comments $0.01

Simple multiple problem @ Dcoder

Problem: You are given 2 numbers N and M. You have to find the smallest number which when multiplied to N makes it a multiple of M.   Input: First line contains T, number of test cases. Each of the next T lines contains two numbers, N and M. Output:...

Lochard 1 minute read 3 Aug 2023 0 comments $0.06

Codewars Kata - Opposite number

Very simple, given an integer or a floating-point number, find its opposite.   Examples: 1: -1 14: -14 -34: 34 def opposite(number): return -number

Lochard 1 minute read 2 Aug 2023 0 comments $0.00

Leetcode - 1089. Duplicate Zeros

Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.   Note that elements beyond the length of the original array are not written. Do the above modifications to the input array in pl...

Lochard 1 minute read 1 Aug 2023 1 comment $0.01

Symmetric Matrix @ Dcoder

Problem: Given a matrix of dimensions N x N. Print "YES"(without quotes) if it is a symmetric matrix, else print "NO"(without quotes).   Input: First line contains N. Each of following N lines contains N integers each, denoting the matrix.   Output:...

Lochard 1 minute read 1 Aug 2023 0 comments $0.02

Wrestling Championship @ Dcoder

Problem: Hulk is participating in a wrestling championship. The contest consists of N fighters including Hulk. The contest is of several stages. At each stage, if number of fighters are X, then there are X/2 fights and X/2 fighters move on to the nex...

Lochard 1 minute read 31 Jul 2023 0 comments $0.01

Codewars Kata - How good are you really?

DESCRIPTION: There was a test in your class and you passed it. Congratulations! But you're an ambitious person. You want to know if you're better than the average student in your class.   You receive an array with your peers' test scores. Now calcula...

Lochard 1 minute read 30 Jul 2023 0 comments $0.06

Codewars 7 kyu Kata - Mumbling

DESCRIPTION: This time no story, no theory. The examples below show you how to write function accum:   Examples: accum("abcd") -> "A-Bb-Ccc-Dddd" accum("RqaEzty") -> "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy" accum("cwAt") -> "C-Ww-Aaa-Tttt" The paramete...

Lochard 1 minute read 29 Jul 2023 0 comments $0.02