The deadline for contributing to a 401K is the last paycheck paid in December. That may not be the last pay period that ends in December. For example if the last pay period ends on Friday the 30th and you get paid on Thursday January 5th, that check is the first in the new year.
The US government has rules regarding how quickly the money needs to be sent to the 401K trustee. It is possible that the money may get there after the first of the year, but the important date for you is the date of the last paycheck in December.
The company form to set the contribution rate (it could also be on a website) will have a deadline to determine if the rate makes the next check or the one after that.
The form will also have a maximum amount as a percentage of the check. Some could allow up to 100% but yours might not. So how much you can put in with the last paycheck or two is up to company policy and your pay rate.
The company forms or website will describe how the company match works. If you were try and put as much as possible into a few checks, it is possible to hit the $18,000 yearly limit in just a small part of the year. In some companies that would mean that you could miss out on company match money, because that would never be more than x% of each check. For example if you were to put $3,000 per check with a base pay of $5,000 every two weeks and if the maximum company match was 5%. After 6 checks you would be done: you would have put in $18,000 and the company would have put in $250 x 6 or $1,500. If you were to spread the money over all 26 checks you would still put in $18,000 but the company would have put in $6,500.