Skip to content

GLAU-TND/python-assignment-2-vaibhav550

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

assignment-2

Problem 1

Given a string s and an integer k, break up the string into multiple lines such that each line has a length of k or less. You must break it up so that words don't break across lines. Each line has to have the maximum possible amount of words. If there's no way to break the text up, then return null.

You can assume that there are no spaces at the ends of the string and that there is exactly one space between each word.

For example, given the string "the quick brown fox jumps over the lazy dog" and k = 10, you should return: ["the quick", "brown fox", "jumps over", "the lazy", "dog"]. No string in the list has a length of more than 10.

Input :
  2 line input 
  the first line contain string s
  the second line contain the integer k
Output:
  list of substrings 

Problem 2

The function at given a list of integers and a number K, return contiguous elements of the list sum to K.

For example, if the list is [1, 2, 3, 4, 5] and K is 9, then it should return [2, 3, 4], since 2 + 3 + 4 = 9.

Input 
  2 line input
  The first line contains list of integer L
  The second line contains integer number  
Output
  list of integers
  None if contiguous element not found 

Problem 3

We have array of integers, 
write a function to determine whether the array could become non-decreasing by modifying at most 1 element.

For example, given the array [10, 5, 7], you should return true, since we can modify the 10 into a 1 to make the array non-decreasing.
Given the array [10, 5, 1], you should return false, since we can't modify any one element to get a non-decreasing array.

Input: 
  1 line input
  the first line contains the list of integers
Output:
  Boolean True/False

About

python-assignment-2-vaibhav550 created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages